An array of event type integers from hs.eventtap.eventTypes
Function called for each matching event. The return value is only meaningful for modify taps.
OptionallistenOnly: boolean
If true, the tap receives events but cannot modify or suppress them. Omit or pass false for a modify tap (the default).
An HSEventTap watcher, or null if the tap could not be created
Create an event tap that calls a function for matching events. Call
.start()to activate it.The callback receives an
HSEventTapEvent. For modify taps (listenOnlyomitted or false), returnhs.eventtap.consume(false) to suppress the event orhs.eventtap.emit(true) to pass it through. For listen-only taps the callback's return value is ignored — events are always delivered to other applications. Requires Accessibility permission.