Module for creating and managing system-wide hotkeys

Types

This module provides the following types:

Properties

This module has no properties.

Methods

hs.hotkey.bind

Bind a hotkey


Declaration

hs.hotkey.bind(mods, key, callbackPressed, callbackReleased) -> HSHotkey

Parameters

  • mods JSValue

    An array of modifier key strings (e.g., ["cmd", "shift"])

  • key string

    The key name or character (e.g., "a", "space", "return")

  • callbackPressed JSValue

    A JavaScript function to call when the hotkey is pressed

  • callbackReleased JSValue

    A JavaScript function to call when the hotkey is released

Return Value

A hotkey object, or nil if binding failed

hs.hotkey.bindSpec

Bind a hotkey with a message description


Declaration

hs.hotkey.bindSpec(mods, key, message, callbackPressed, callbackReleased) -> HSHotkey

Parameters

  • mods JSValue

    An array of modifier key strings

  • key string

    The key name or character

  • message string

    A description of what this hotkey does (currently unused, for future features)

  • callbackPressed JSValue

    A JavaScript function to call when the hotkey is pressed

  • callbackReleased JSValue

    A JavaScript function to call when the hotkey is released

Return Value

A hotkey object, or nil if binding failed

hs.hotkey.getKeyCodeMap

Get the system-wide mapping of key names to key codes


Declaration

hs.hotkey.getKeyCodeMap() -> {[key: string]: number}

Parameters

None

Return Value

A dictionary mapping key names to numeric key codes

hs.hotkey.getModifierMap

Get the mapping of modifier names to modifier flags


Declaration

hs.hotkey.getModifierMap() -> {[key: string]: number}

Parameters

None

Return Value

A dictionary mapping modifier names to their numeric values