<!--
{
  "documentType" : "article",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/quartz-event-services",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Quartz Event Services"
}
-->

# Quartz Event Services

Provides features for managing *event taps*—filters for observing and altering the stream of low-level user input events in macOS.

## Discussion

Event taps make it possible to monitor and filter input events from several points within the system, prior to their delivery to a foreground application. Event taps complement and extend the capabilities of the Carbon event monitor mechanism, which allows an application to observe input events delivered to other processes.

Event taps are designed to serve as a Section 508 enabling technology. For example, consider a software system to assist a person with language impairments, designed to perform keyboard filtering with spoken review. Such a system could use an event tap to monitor all keystrokes, perform dictionary checks and matches, and recite the assembled word back to the user on detection of a word break in the input stream. If acceptable to the user, as indicated by an additional input keystroke or other gesture, the events would be posted into the system for delivery to the foreground application.

Introduced in OS X version 10.4, event taps provide functionality similar to the Win32 functions `SetWinEventHook` when used to establish an out-of-context event hook, and `SendInput`. Quartz Event Services also includes an older set of event-related functions declared in the file `CGRemoteOperation.h`. These functions are still supported, but they are not recommended for new development.

## Topics

### Working With Events

[`typeID`](/documentation/CoreGraphics/CGEvent/typeID)

Returns the type identifier for the opaque type `CGEventRef`.

[`init(source:)`](/documentation/CoreGraphics/CGEvent/init(source:))

Returns a new Quartz event.

[`CGEventCreateData`](/documentation/CoreGraphics/CGEventCreateData)

Returns a flattened data representation of a Quartz event.

[`init(withDataAllocator:data:)`](/documentation/CoreGraphics/CGEvent/init(withDataAllocator:data:))

Returns a Quartz event created from a flattened data representation of the event.

[`init(mouseEventSource:mouseType:mouseCursorPosition:mouseButton:)`](/documentation/CoreGraphics/CGEvent/init(mouseEventSource:mouseType:mouseCursorPosition:mouseButton:))

Returns a new Quartz mouse event.

[`init(keyboardEventSource:virtualKey:keyDown:)`](/documentation/CoreGraphics/CGEvent/init(keyboardEventSource:virtualKey:keyDown:))

Returns a new Quartz keyboard event.

[`CGEventCreateScrollWheelEvent`](/documentation/CoreGraphics/CGEventCreateScrollWheelEvent)

Returns a new Quartz scrolling event.

[`copy()`](/documentation/CoreGraphics/CGEvent/copy())

Returns a copy of an existing Quartz event.

[`init(event:)`](/documentation/CoreGraphics/CGEventSource/init(event:))

Returns a Quartz event source created from an existing Quartz event.

[`setSource(_:)`](/documentation/CoreGraphics/CGEvent/setSource(_:))

Sets the event source of a Quartz event.

[`type`](/documentation/CoreGraphics/CGEvent/type)

Returns the event type of a Quartz event (left mouse down, for example).

[`CGEventSetType`](/documentation/CoreGraphics/CGEventSetType)

Sets the event type of a Quartz event (left mouse down, for example).

[`timestamp`](/documentation/CoreGraphics/CGEvent/timestamp)

Returns the timestamp of a Quartz event.

[`CGEventSetTimestamp`](/documentation/CoreGraphics/CGEventSetTimestamp)

Sets the timestamp of a Quartz event.

[`location`](/documentation/CoreGraphics/CGEvent/location)

Returns the location of a Quartz mouse event.

[`unflippedLocation`](/documentation/CoreGraphics/CGEvent/unflippedLocation)

Returns the location of a Quartz mouse event.

[`CGEventSetLocation`](/documentation/CoreGraphics/CGEventSetLocation)

Sets the location of a Quartz mouse event.

[`flags`](/documentation/CoreGraphics/CGEvent/flags)

Returns the event flags of a Quartz event.

[`CGEventSetFlags`](/documentation/CoreGraphics/CGEventSetFlags)

Sets the event flags of a Quartz event.

[`keyboardGetUnicodeString(maxStringLength:actualStringLength:unicodeString:)`](/documentation/CoreGraphics/CGEvent/keyboardGetUnicodeString(maxStringLength:actualStringLength:unicodeString:))

Returns the Unicode string associated with a Quartz keyboard event.

[`keyboardSetUnicodeString(stringLength:unicodeString:)`](/documentation/CoreGraphics/CGEvent/keyboardSetUnicodeString(stringLength:unicodeString:))

Sets the Unicode string associated with a Quartz keyboard event.

[`getIntegerValueField(_:)`](/documentation/CoreGraphics/CGEvent/getIntegerValueField(_:))

Returns the integer value of a field in a Quartz event.

[`setIntegerValueField(_:value:)`](/documentation/CoreGraphics/CGEvent/setIntegerValueField(_:value:))

Sets the integer value of a field in a Quartz event.

[`getDoubleValueField(_:)`](/documentation/CoreGraphics/CGEvent/getDoubleValueField(_:))

Returns the floating-point value of a field in a Quartz event.

[`setDoubleValueField(_:value:)`](/documentation/CoreGraphics/CGEvent/setDoubleValueField(_:value:))

Sets the floating-point value of a field in a Quartz event.

### Working With Event Taps

[`tapCreate(tap:place:options:eventsOfInterest:callback:userInfo:)`](/documentation/CoreGraphics/CGEvent/tapCreate(tap:place:options:eventsOfInterest:callback:userInfo:))

Creates an event tap.

[`tapCreateForPSN(processSerialNumber:place:options:eventsOfInterest:callback:userInfo:)`](/documentation/CoreGraphics/CGEvent/tapCreateForPSN(processSerialNumber:place:options:eventsOfInterest:callback:userInfo:))

Creates an event tap for a specified process.

[`tapEnable(tap:enable:)`](/documentation/CoreGraphics/CGEvent/tapEnable(tap:enable:))

Enables or disables an event tap.

[`tapIsEnabled(tap:)`](/documentation/CoreGraphics/CGEvent/tapIsEnabled(tap:))

Returns a Boolean value indicating whether an event tap is enabled.

[`tapPostEvent(_:)`](/documentation/CoreGraphics/CGEvent/tapPostEvent(_:))

Posts a Quartz event from an event tap into the event stream.

[`post(tap:)`](/documentation/CoreGraphics/CGEvent/post(tap:))

Posts a Quartz event into the event stream at a specified location.

[`postToPSN(processSerialNumber:)`](/documentation/CoreGraphics/CGEvent/postToPSN(processSerialNumber:))

Posts a Quartz event into the event stream for a specific application.

[`CGGetEventTapList(_:_:_:)`](/documentation/CoreGraphics/CGGetEventTapList(_:_:_:))

Gets a list of currently installed event taps.

[`CGEventMaskBit`](/documentation/CoreGraphics/CGEventMaskBit)

Generates an event mask for a single type of event.

### Working With Event Sources

[`typeID`](/documentation/CoreGraphics/CGEventSource/typeID)

Returns the type identifier for the opaque type `CGEventSourceRef`.

[`init(stateID:)`](/documentation/CoreGraphics/CGEventSource/init(stateID:))

Returns a Quartz event source created with a specified source state.

[`keyboardType`](/documentation/CoreGraphics/CGEventSource/keyboardType)

Returns the keyboard type to be used with a Quartz event source.

[`CGEventSourceSetKeyboardType`](/documentation/CoreGraphics/CGEventSourceSetKeyboardType)

Sets the keyboard type to be used with a Quartz event source.

[`sourceStateID`](/documentation/CoreGraphics/CGEventSource/sourceStateID)

Returns the source state associated with a Quartz event source.

[`buttonState(_:button:)`](/documentation/CoreGraphics/CGEventSource/buttonState(_:button:))

Returns a Boolean value indicating the current button state of a Quartz event source.

[`keyState(_:key:)`](/documentation/CoreGraphics/CGEventSource/keyState(_:key:))

Returns a Boolean value indicating the current keyboard state of a Quartz event source.

[`flagsState(_:)`](/documentation/CoreGraphics/CGEventSource/flagsState(_:))

Returns the current flags of a Quartz event source.

[`secondsSinceLastEventType(_:eventType:)`](/documentation/CoreGraphics/CGEventSource/secondsSinceLastEventType(_:eventType:))

Returns the elapsed time since the last event for a Quartz event source.

[`counterForEventType(_:eventType:)`](/documentation/CoreGraphics/CGEventSource/counterForEventType(_:eventType:))

Returns a count of events of a given type seen since the window server started.

[`userData`](/documentation/CoreGraphics/CGEventSource/userData)

Returns the 64-bit user-specified data for a Quartz event source.

[`CGEventSourceSetUserData`](/documentation/CoreGraphics/CGEventSourceSetUserData)

Sets the 64-bit user-specified data for a Quartz event source.

[`getLocalEventsFilterDuringSuppressionState(_:)`](/documentation/CoreGraphics/CGEventSource/getLocalEventsFilterDuringSuppressionState(_:))

Returns the mask that indicates which classes of local hardware events are enabled during event suppression.

[`setLocalEventsFilterDuringSuppressionState(_:state:)`](/documentation/CoreGraphics/CGEventSource/setLocalEventsFilterDuringSuppressionState(_:state:))

Sets the mask that indicates which classes of local hardware events are enabled during event suppression.

[`localEventsSuppressionInterval`](/documentation/CoreGraphics/CGEventSource/localEventsSuppressionInterval)

Returns the interval that local hardware events may be suppressed following the posting of a Quartz event.

[`CGEventSourceSetLocalEventsSuppressionInterval`](/documentation/CoreGraphics/CGEventSourceSetLocalEventsSuppressionInterval)

Sets the interval that local hardware events may be suppressed following the posting of a Quartz event.

[`pixelsPerLine`](/documentation/CoreGraphics/CGEventSource/pixelsPerLine)

Gets the scale of pixels per line in a scrolling event source.

[`CGEventSourceSetPixelsPerLine`](/documentation/CoreGraphics/CGEventSourceSetPixelsPerLine)

Sets the scale of pixels per line in a scrolling event source.

### Callbacks

[`CGEventTapCallBack`](/documentation/CoreGraphics/CGEventTapCallBack)

A client-supplied callback function that’s invoked whenever an associated event tap receives a Quartz event.

### Data Types

[`CGButtonCount`](/documentation/CoreGraphics/CGButtonCount)

Represents the number of buttons being set in a synthetic mouse event.

[`CGCharCode`](/documentation/CoreGraphics/CGCharCode)

Represents a character generated by pressing one or more keys on a keyboard.

[`CGEventMask`](/documentation/CoreGraphics/CGEventMask)

Defines a mask that identifies the set of Quartz events to be observed in an event tap.

[`CGEvent`](/documentation/CoreGraphics/CGEvent)

Defines an opaque type that represents a low-level hardware event.

[`CGEventSourceKeyboardType`](/documentation/CoreGraphics/CGEventSourceKeyboardType)

Defines a code that represents the type of keyboard used with a specified event source.

[`CGEventSource`](/documentation/CoreGraphics/CGEventSource)

Defines an opaque type that represents the source of a Quartz event.

[`CGEventTapInformation`](/documentation/CoreGraphics/CGEventTapInformation)

Defines the structure used to report information about event taps.

[`CGEventTapProxy`](/documentation/CoreGraphics/CGEventTapProxy)

Defines an opaque type that represents state within the client application that’s associated with an event tap.

[`CGEventTimestamp`](/documentation/CoreGraphics/CGEventTimestamp)

Defines the elapsed time in nanoseconds since startup that a Quartz event occurred.

[`CGKeyCode`](/documentation/CoreGraphics/CGKeyCode)

Represents the virtual key codes used in keyboard events.

[`CGWheelCount`](/documentation/CoreGraphics/CGWheelCount)

Represents the number of wheels being set in a scroll wheel event.

### Constants

[`CGEventField`](/documentation/CoreGraphics/CGEventField)

Constants used as keys to access specialized fields in low-level events.

[`CGEventFilterMask`](/documentation/CoreGraphics/CGEventFilterMask)

Specify masks for classes of low-level events that can be filtered during event suppression states.

[`CGEventFlags`](/documentation/CoreGraphics/CGEventFlags)

Constants that indicate the modifier key state at the time an event is created, as well as other event-related states.

[`CGEventSourceStateID`](/documentation/CoreGraphics/CGEventSourceStateID)

Constants that specify the possible source states of an event source.

[Event Source Token](/documentation/CoreGraphics/event-source-token)

Specifies any input event type.

[`CGEventSuppressionState`](/documentation/CoreGraphics/CGEventSuppressionState)

Specify the event suppression states that can occur after posting an event.

[`CGEventTapLocation`](/documentation/CoreGraphics/CGEventTapLocation)

Constants that specify possible tapping points for events.

[`CGEventTapOptions`](/documentation/CoreGraphics/CGEventTapOptions)

Constants that specify whether a new event tap is an active filter or a passive listener.

[`CGEventTapPlacement`](/documentation/CoreGraphics/CGEventTapPlacement)

Constants that specify where a new event tap is inserted into the list of active event taps.

[`CGEventType`](/documentation/CoreGraphics/CGEventType)

Constants that specify the different types of input events.

[Event Type Mask](/documentation/CoreGraphics/event-type-mask)

Specifies an event mask that represents all event types.

[`CGMouseButton`](/documentation/CoreGraphics/CGMouseButton)

Constants that specify buttons on a one, two, or three-button mouse.

[`CGEventMouseSubtype`](/documentation/CoreGraphics/CGEventMouseSubtype)

Constants used with the [`CGEventField.mouseEventSubtype`](/documentation/CoreGraphics/CGEventField/mouseEventSubtype) event field.

[`CGScrollEventUnit`](/documentation/CoreGraphics/CGScrollEventUnit)

Constants that specify the unit of measurement for a scrolling event.

### Deprecated Functions

[`CGPostKeyboardEvent(_:_:_:)`](/documentation/CoreGraphics/CGPostKeyboardEvent(_:_:_:))

Synthesizes a low-level keyboard event on the local machine.

[`CGPostMouseEvent`](/documentation/CoreGraphics/CGPostMouseEvent)

Synthesizes a low-level mouse-button event on the local machine.

[`CGPostScrollWheelEvent`](/documentation/CoreGraphics/CGPostScrollWheelEvent)

Synthesizes a low-level scrolling event on the local machine.

[`CGEnableEventStateCombining(_:)`](/documentation/CoreGraphics/CGEnableEventStateCombining(_:))

Enables or disables the merging of actual key and mouse state with the application-specified state in a synthetic event.

[`CGInhibitLocalEvents(_:)`](/documentation/CoreGraphics/CGInhibitLocalEvents(_:))

Turns off local hardware events in the current session.

[`CGSetLocalEventsFilterDuringSuppressionState(_:_:)`](/documentation/CoreGraphics/CGSetLocalEventsFilterDuringSuppressionState(_:_:))

Filters local hardware events from the keyboard and mouse during the short interval after a synthetic event is posted.

[`CGSetLocalEventsFilterDuringSupressionState`](/documentation/CoreGraphics/CGSetLocalEventsFilterDuringSupressionState)

[`CGSetLocalEventsSuppressionInterval(_:)`](/documentation/CoreGraphics/CGSetLocalEventsSuppressionInterval(_:))

Sets the time interval in seconds that local hardware events are suppressed after posting a synthetic event.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)