hammerspoon2-docs
    Preparing search index...

    Class HSEventTapEvent

    An input event captured or constructed by hs.eventtap. Objects of this type are passed to event tap callbacks and can also be created directly via the factory methods on hs.eventtap. Properties can be inspected and modified before the event is passed through or posted back to the system.

    Index

    Constructors

    Properties

    buttonNumber: number

    The mouse button number for mouse events (0=left, 1=right, 2=middle)

    characters: string | null

    The Unicode characters produced by this keyboard event, or null for non-keyboard events

    flags: string[]

    An array of active modifier key names (e.g. ["cmd", "shift"]). When a device-specific modifier is detected, both the generic and side-specific names are included — e.g. pressing the left Command key yields ["cmd", "leftCmd"].

    keyCode: number

    The virtual key code for keyboard events (get/set)

    location: Record<string, number>

    The event's screen position as {x, y} in Hammerspoon screen coordinates (top-left origin of primary display, y increases downward, matching hs.screen).

    rawFlags: number

    The raw modifier flags bitmask (get/set). Use values from hs.eventtap.modifierFlags.

    scrollingDeltaX: number

    The horizontal scroll delta for scroll wheel events

    scrollingDeltaY: number

    The vertical scroll delta for scroll wheel events

    type: number

    The numeric event type, matching a value in hs.eventtap.eventTypes

    typeName: string

    Type name for introspection

    Methods

    • Create an independent copy of this event

      Returns HSEventTapEvent | null

      A new HSEventTapEvent with the same properties, or null if the copy failed

    post

    • post(app: HSApplication | null): void

      Post this event to the HID event stream, optionally targeting a specific application. When app is omitted or null, the event is posted to the global HID stream and delivered by the OS as if a real input device generated it. When an application is provided, the event is delivered directly to that process by PID.

      Parameters

      • app: HSApplication | null

        The application to target, or null/omit to post globally

      Returns void