Function

CGEventSourceCounterForEventType

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

Declaration

uint32_t CGEventSourceCounterForEventType(CGEventSourceStateID stateID, CGEventType eventType);

Parameters

sourceState

The source state to access. Pass one of the constants listed in CGEventSourceStateID.

eventType

The event type to access. To get the count of input events—keyboard, mouse, or tablet—specify kCGAnyInputEventType.

Return Value

The count of events of the specified type seen since the window server started.

Discussion

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 kCGEventFlagsChanged events, not kCGEventKeyDown 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.

See Also

Working With Event Sources

CGEventSourceGetTypeID

Returns the type identifier for the opaque type CGEventSourceRef.

CGEventSourceCreate

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

CGEventSourceGetKeyboardType

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

CGEventSourceSetKeyboardType

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

CGEventSourceGetSourceStateID

Returns the source state associated with a Quartz event source.

CGEventSourceButtonState

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

CGEventSourceKeyState

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

CGEventSourceFlagsState

Returns the current flags of a Quartz event source.

CGEventSourceSecondsSinceLastEventType

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

CGEventSourceGetUserData

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

CGEventSourceSetUserData

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

CGEventSourceGetLocalEventsFilterDuringSuppressionState

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

CGEventSourceSetLocalEventsFilterDuringSuppressionState

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

CGEventSourceGetLocalEventsSuppressionInterval

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

CGEventSourceSetLocalEventsSuppressionInterval

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

CGEventSourceGetPixelsPerLine

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

CGEventSourceSetPixelsPerLine

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