Contents

CGPostKeyboardEvent(_:_:_:)

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

Declaration

func CGPostKeyboardEvent(_ keyChar: CGCharCode, _ virtualKey: CGKeyCode, _ keyDown: boolean_t) -> CGError

Parameters

  • keyChar:

    The value of the character to generate, or 0 to specify that the system should guess an appropriate value based on the default key mapping.

  • virtualKey:

    The virtual key code for the event. See Cgkeycode.

  • keyDown:

    Pass true to specify that the key position is down; otherwise, pass false.

Return Value

A result code. See the result codes described in Quartz Display Services.

Discussion

This function is not recommended for general use because of undocumented special cases and undesirable side effects. The recommended replacement for this function is init(keyboardEventSource:virtualKey:keyDown:), which allows you to create a keyboard event and customize the event before posting it to the event system.

See Also

Functions