hammerspoon2-docs
    Preparing search index...

    Namespace keycodes

    Access information about the current keyboard layout and input sources, and respond to changes.

    console.log("Layout: " + hs.keycodes.currentLayout())
    console.log("Source ID: " + hs.keycodes.currentSourceID())
    // Look up a keycode by name
    const code = hs.keycodes.map["a"] // e.g. 0 on ANSI US
    // Look up a name by keycode
    const name = hs.keycodes.map["0"] // e.g. "a"
    hs.keycodes.setLayout("British")
    
    hs.keycodes.addWatcher(() => {
    console.log("Switched to: " + hs.keycodes.currentLayout())
    })

    Variables

    map

    Functions

    addWatcher
    currentLayout
    currentMethod
    currentSourceID
    layouts
    methods
    removeWatcher
    setLayout
    setMethod
    setSourceID