<!--
{
  "availability" : [
    "driverkit: 19.0.0 -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "HIDDriverKit",
  "identifier" : "/documentation/HIDDriverKit/IOHIDEventService/dispatchKeyboardEvent",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HIDDriverKit"
    ],
    "preciseIdentifier" : "c:@S@IOHIDEventService@F@dispatchKeyboardEvent#k#i#i#i#i#b#"
  },
  "title" : "dispatchKeyboardEvent"
}
-->

# dispatchKeyboardEvent

Dispatches a keyboard-related event to the system.

```
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 [Usage Pages](/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 [HID Usage Tables](/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 [`IOHIDKeyboardEventOptions`](/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

<doc://com.apple.documentation/documentation/DriverKit/kIOReturnSuccess> on success, or another value if an error occurs. See <doc://com.apple.documentation/documentation/DriverKit/error-codes>.

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)