hammerspoon2-docs
    Preparing search index...

    Class HSHotkeyModal

    A group of hotkeys that are activated and deactivated together. Obtain instances via hs.hotkey.modal.create() — do not instantiate directly.

    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
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    enterFn: (() => void) | null

    Called when the modal is entered

    exitFn: (() => void) | null

    Called when the modal is exited

    isActive: boolean

    Whether the modal is currently active

    Methods

    • Add a hotkey that is active only while this modal is entered

      Parameters

      • mods: string[]

        Modifier keys for the hotkey

      • key: string

        Key name for the hotkey

      • callbackPressed: (() => void) | null

        Called when the key is pressed, or null

      • callbackReleased: (() => void) | null

        Called when the key is released, or null

      Returns HSHotkeyModal

      This modal, for chaining

    • Destroy the modal and all its hotkeys without calling exitFn

      Returns void

    • Activate the modal: enable its hotkeys and disable the trigger hotkey

      Returns HSHotkeyModal

      This modal, for chaining

    • Deactivate the modal: disable its hotkeys and re-enable the trigger hotkey

      Returns HSHotkeyModal

      This modal, for chaining