HSEventTapHotkey
TypeA keyboard shortcut binding backed by an event tap. Supports fn modifier and left/right modifier
key distinction. Obtain instances via hs.eventtap.bindHotkey() — do not instantiate directly.
Properties
keyCode
number
The virtual key code this hotkey currently matches. For a hotkey bound by key name
this follows the keyboard layout (see `hs.eventtap.followsKeyboardLayout`).
onPressed
function | null
The callback function to be called when the hotkey is pressed, or null to remove it
onReleased
function | null
The callback function to be called when the hotkey is released, or null to remove it
Methods
enable() -> boolean
Enable the hotkey
Declaration
enable() -> boolean
Returns
boolean
True if the hotkey was enabled, otherwise False
Notes
An enabled hotkey, and its callbacks, stay alive until it's disabled, even if you don't keep a reference to it
Example
const hk = hs.eventtap.bindHotkey(["fn"], "f1", () => {}, null)
hk.enable()
disable() -> None
Disable the hotkey
Declaration
disable() -> None
Returns
None
Example
const hk = hs.eventtap.bindHotkey(["fn"], "f1", () => {}, null)
hk.disable()
isEnabled() -> boolean
Check if the hotkey is currently enabled
Declaration
isEnabled() -> boolean
Returns
boolean
True if the hotkey is enabled, otherwise False
Example
const hk = hs.eventtap.bindHotkey(["fn"], "f1", () => {}, null)
console.log(hk.isEnabled())