hammerspoon2-docs
    Preparing search index...

    Function bindSpec

    • Bind a hotkey from a single options object. Like hs.hotkey.bind()/create(), but also accepts a message and a repeat callback. message is available on any hotkey (not just ones created via bindSpec()) by setting .message directly on the returned object; see hs.hotkey's message property for exactly when it is shown.

      Parameters

      • spec: {
            key: string | number;
            message?: string;
            mods: string[];
            pressed?: (() => void) | null;
            released?: (() => void) | null;
            repeat?: (() => void) | null;
        }

        The hotkey to bind

        • key: string | number

          Key name or character (e.g. "h"), or a numeric key code

        • Optionalmessage?: string

          A description shown as a toast when the hotkey fires

        • mods: string[]

          Modifier keys (e.g. ["cmd", "shift"])

        • Optionalpressed?: (() => void) | null

          Called when the hotkey is pressed

        • Optionalreleased?: (() => void) | null

          Called when the hotkey is released

        • Optionalrepeat?: (() => void) | null

          Called repeatedly while the hotkey is held down

      Returns any

      A hotkey object, or null if binding failed