---
title: "CGPostKeyboardEvent(_:_:_:)"
framework: coregraphics
role: symbol
role_heading: Function
path: "coregraphics/cgpostkeyboardevent(_:_:_:)"
---

# CGPostKeyboardEvent(_:_:_:)

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

## Declaration

```swift
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 doc://com.apple.coregraphics/documentation/CoreGraphics/CGKeyCode.
- `keyDown`: Pass true to specify that the key position is down; otherwise, pass false.

## Return Value

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

## Discussion

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

- [CGAcquireDisplayFadeReservation(_:_:)](coregraphics/cgacquiredisplayfadereservation(_:_:).md)
- [CGAssociateMouseAndMouseCursorPosition(_:)](coregraphics/cgassociatemouseandmousecursorposition(_:).md)
- [CGBeginDisplayConfiguration(_:)](coregraphics/cgbegindisplayconfiguration(_:).md)
- [CGCancelDisplayConfiguration(_:)](coregraphics/cgcanceldisplayconfiguration(_:).md)
- [CGCaptureAllDisplays()](coregraphics/cgcapturealldisplays().md)
- [CGCaptureAllDisplaysWithOptions(_:)](coregraphics/cgcapturealldisplayswithoptions(_:).md)
- [CGCompleteDisplayConfiguration(_:_:)](coregraphics/cgcompletedisplayconfiguration(_:_:).md)
- [CGConfigureDisplayFadeEffect(_:_:_:_:_:_:)](coregraphics/cgconfiguredisplayfadeeffect(_:_:_:_:_:_:).md)
- [CGConfigureDisplayMirrorOfDisplay(_:_:_:)](coregraphics/cgconfiguredisplaymirrorofdisplay(_:_:_:).md)
- [CGConfigureDisplayMode(_:_:_:)](coregraphics/cgconfiguredisplaymode(_:_:_:).md)
- [CGConfigureDisplayOrigin(_:_:_:_:)](coregraphics/cgconfiguredisplayorigin(_:_:_:_:).md)
- [CGConfigureDisplayStereoOperation(_:_:_:_:)](coregraphics/cgconfiguredisplaystereooperation(_:_:_:_:).md)
- [CGConfigureDisplayWithDisplayMode(_:_:_:_:)](coregraphics/cgconfiguredisplaywithdisplaymode(_:_:_:_:).md)
- [CGCursorIsDrawnInFramebuffer()](coregraphics/cgcursorisdrawninframebuffer().md)
- [CGCursorIsVisible()](coregraphics/cgcursorisvisible().md)
