---
title: dispatchKeyboardEvent
framework: hiddriverkit
role: symbol
role_heading: Instance Method
path: hiddriverkit/iohideventservice/dispatchkeyboardevent
---

# dispatchKeyboardEvent

Dispatches a keyboard-related event to the system.

## Declaration

```occ
virtual kern_return_t dispatchKeyboardEvent(uint64_t timeStamp, uint32_t usagePage, uint32_t usage, uint32_t value, IOOptionBits options, bool repeat);
```

## Parameters

- `timeStamp`: The timestamp of the event. Use the timestamp of the report element that is the source of the event.
- `usagePage`: The HID usage page to associate with the event. For a list of possible values, see doc://com.apple.hiddriverkit/documentation/HIDDriverKit/Usage-Pages-enum.
- `usage`: The HID usage code indicating the specific type of the event. For a list of possible usage values, see doc://com.apple.hiddriverkit/documentation/HIDDriverKit/hid-usage-tables.
- `value`: The value associated with the event.
- `options`: Additional options for keyboard events. Specify 0 for no options. For a list of other values, see doc://com.apple.hiddriverkit/documentation/HIDDriverKit/IOHIDKeyboardEventOptions.
- `repeat`: The autorepeat behavior to apply when the user holds down a key. Specify true to apply the default behavior, which repeats the key event after a user-configurable amount of time elapses. Specify false to prevent the delivery of repeat events.

## Return Value

Return Value kIOReturnSuccess on success, or another value if an error occurs. See Error Codes.

## Discussion

Discussion Call this method from your event service to dispatch a keyboard event to the system. Typically, you call this method when handling a report from the device, after you determine that the report contains a keyboard-related event.

## See Also

### Dispatching Events

- [dispatchRelativePointerEvent](hiddriverkit/iohideventservice/dispatchrelativepointerevent.md)
- [dispatchAbsolutePointerEvent](hiddriverkit/iohideventservice/dispatchabsolutepointerevent.md)
- [dispatchDigitizerStylusEvent](hiddriverkit/iohideventservice/dispatchdigitizerstylusevent.md)
- [dispatchDigitizerTouchEvent](hiddriverkit/iohideventservice/dispatchdigitizertouchevent.md)
- [dispatchRelativeScrollWheelEvent](hiddriverkit/iohideventservice/dispatchrelativescrollwheelevent.md)
- [dispatchEvent](hiddriverkit/iohideventservice/dispatchevent.md)
- [IOHIDKeyboardEventOptions](hiddriverkit/iohidkeyboardeventoptions.md)
- [IOHIDPointerEventOptions](hiddriverkit/iohidpointereventoptions.md)
- [IOHIDScrollEventOptions](hiddriverkit/iohidscrolleventoptions.md)
