API Docs

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(mods, key, callbackPressed, callbackReleased) -> HSHotkey

Bind a hotkey
hs.hotkey.bind(mods, key, callbackPressed, callbackReleased) -> HSHotkey
Name Type Description
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
HSHotkey
A hotkey object, or nil if binding failed
hs.hotkey.bind(["cmd","shift"], "h", () => {
    console.log("Hello!")
})

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

Bind a hotkey with a message description
hs.hotkey.bindSpec(mods, key, message, callbackPressed, callbackReleased) -> HSHotkey
Name Type Description
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
HSHotkey
A hotkey object, or nil if binding failed
hs.hotkey.bindSpec(["cmd"], "space", "Spotlight-like", () => {
    console.log("pressed")
}, null)

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

Get the system-wide mapping of key names to key codes
hs.hotkey.getKeyCodeMap() -> {[key: string]: number}
{[key: string]: number}
A dictionary mapping key names to numeric key codes
console.log(hs.hotkey.getKeyCodeMap())

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

Get the mapping of modifier names to modifier flags
hs.hotkey.getModifierMap() -> {[key: string]: number}
{[key: string]: number}
A dictionary mapping modifier names to their numeric values
console.log(hs.hotkey.getModifierMap())