<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/CGEventTapCallBack",
  "metadataVersion" : "0.1.0",
  "role" : "Type Alias",
  "symbol" : {
    "kind" : "Type Alias",
    "modules" : [
      "Core Graphics"
    ],
    "preciseIdentifier" : "c:@T@CGEventTapCallBack"
  },
  "title" : "CGEventTapCallBack"
}
-->

# CGEventTapCallBack

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

```
typealias CGEventTapCallBack = (CGEventTapProxy, CGEventType, CGEvent, UnsafeMutableRawPointer?) -> Unmanaged<CGEvent>?
```

## Parameters

`proxy`

A proxy for the event tap. See [`CGEventTapProxy`](/documentation/CoreGraphics/CGEventTapProxy). This callback function may pass this proxy to other functions such as the event-posting routines.

`type`

The event type of this event. See [`CGEventType`](/documentation/CoreGraphics/CGEventType).

`event`

The incoming event. This event is owned by the caller, and you do not need to release it.

`refcon`

A pointer to user-defined data. You specify this pointer when you create the event tap. Several different event taps could use the same callback function, each tap with its own user-defined data.

## Discussion

If the event tap is an active filter, your callback function should return one of the following:

- The (possibly modified) event that is passed in. This event is passed back to the event system.
- A newly-constructed event. After the new event has been passed back to the event system, the new event will be released along with the original event.
- `NULL` if the event passed in is to be deleted.

If the event tap is an passive listener, your callback function may return the event that is passed in, or `NULL`. In either case, the event stream is not affected.

---

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)