Returns a count of events of a given type seen since the window server started.
- macOS 10.4+
- Mac Catalyst 13.0+
- Core Graphics
The source state to access. Pass one of the constants listed in
Source State ID
The event type to access. To get the count of input events—keyboard, mouse, or tablet—specify
CGAny Input Event Type
The count of events of the specified type seen since the window server started.
Quartz provides these counters for applications that monitor user activity. For example, an application could prompt a typist to take a break to reduce repetitive stress injuries.
Modifier keys produce
k events, not
k events, and do so both on press and release. The volume, brightness, and CD eject keys on some keyboards (both desktop and laptop) do not generate key up or key down events.
For various reasons, the number of key up and key down events may not be the same when all keyboard keys are up. As a result, a mismatch does not necessarily indicate that some keys are down.
Key autorepeat events are not counted.