hammerspoon2-docs
    Preparing search index...

    Class HSEventTap

    An event tap watcher that intercepts input events from the system. Obtain instances via hs.eventtap.addWatcher() — do not instantiate directly.

    const tap = hs.eventtap.addWatcher([hs.eventtap.eventTypes.keyDown], (event) => {
    console.log("Key pressed: " + event.keyCode)
    })
    Index

    Constructors

    Properties

    identifier: string

    A unique identifier for this tap

    listenOnly: boolean

    Whether this tap was created as listen-only (events are observed but never modified or suppressed)

    Methods

    • Whether this tap has been registered with macOS

      Returns boolean

      True if the tap has been created

    • Whether this tap is currently active

      Returns boolean

      True if the tap is running

    • Replace the callback function

      Parameters

      • callback: (event: HSEventTapEvent) => boolean | undefined

        A function called for each matching event. Return false to consume (suppress) the event; return anything else to pass it through.

      Returns HSEventTap

      This tap, for chaining

    • Start receiving events. Requires Accessibility permission.

      Returns HSEventTap

      This tap, for chaining