hammerspoon2-docs
    Preparing search index...

    Namespace eventtap

    Monitor and synthesise macOS input events: keyboard, mouse, and scroll wheel. All coordinate parameters use Hammerspoon screen coordinates: the origin (0, 0) is at the top-left of the primary display and y increases downward, matching hs.screen.

    const tap = hs.eventtap.addWatcher(
    [hs.eventtap.eventTypes.keyDown],
    (event) => {
    console.log("Key pressed: " + event.keyCode)
    return hs.eventtap.emit // pass the event through
    }
    )
    tap.start()

    Returning hs.eventtap.consume from the callback prevents the event from reaching

    const blocker = hs.eventtap.addWatcher(
    [hs.eventtap.eventTypes.leftMouseDown],
    (event) => hs.eventtap.consume
    )
    blocker.start()
    hs.eventtap.keyStroke(["cmd"], "c")
    hs.eventtap.leftClick(500, 300)

    Variables

    consume
    emit
    eventTypes
    modifierFlags

    Functions

    addWatcher
    checkMouseButtons
    currentModifiers
    doubleClickInterval
    doubleLeftClick
    keyRepeatDelay
    keyRepeatInterval
    keyStroke
    keyStrokes
    leftClick
    makeKeyEvent
    makeKeyEventWithCode
    makeMouseEvent
    makeScrollWheelEvent
    middleClick
    mouseLocation
    removeWatcher
    rightClick
    scrollWheel