HSHotkeyModal
TypeA group of hotkeys that are activated and deactivated together.
Obtain instances via hs.hotkey.modal.create() — do not instantiate directly.
Example
const m = hs.hotkey.modal.create(['cmd', 'shift'], 'h')
m.bind([], 'j', () => console.log('j pressed in modal'), null)
m.enterFn = () => console.log('modal entered')
m.exitFn = () => console.log('modal exited')
// Press Cmd+Shift+H to enter, then J triggers the modal hotkey
Properties
Methods
bind(mods, key, callbackPressed, callbackReleased) -> HSHotkeyModal
Add a hotkey that is active only while this modal is entered
Declaration
bind(mods, key, callbackPressed, callbackReleased) -> HSHotkeyModal
Parameters
| Name | Type | Description |
|---|---|---|
| mods | string[] | Modifier keys for the hotkey |
| key | string | Key name for the hotkey |
| callbackPressed | function | Called when the key is pressed, or null |
| callbackReleased | function | Called when the key is released, or null |
Returns
HSHotkeyModal
This modal, for chaining
Example
m.bind(['shift'], 'a', () => console.log('shift-a'), null)
.bind([], 'escape', () => m.exit(), null)
enter() -> HSHotkeyModal
Activate the modal: enable its hotkeys and disable the trigger hotkey
Declaration
enter() -> HSHotkeyModal
Returns
HSHotkeyModal
This modal, for chaining
Example
m.enter()
exit() -> HSHotkeyModal
Deactivate the modal: disable its hotkeys and re-enable the trigger hotkey
Declaration
exit() -> HSHotkeyModal
Returns
HSHotkeyModal
This modal, for chaining
Example
m.exit()
destroy() -> None
Destroy the modal and all its hotkeys without calling exitFn
Declaration
destroy() -> None
Returns
None
Example
m.destroy()