MCPcopy Create free account
hub / github.com/TanStack/hotkeys / dispatchKey

Function dispatchKey

packages/hotkeys/tests/sequence-manager.test.ts:11–19  ·  view source on GitHub ↗

* Helper to create and dispatch a KeyboardEvent

(
  key: string,
  options: { eventType?: 'keydown' | 'keyup' } = {},
)

Source from the content-addressed store, hash-verified

9 * Helper to create and dispatch a KeyboardEvent
10 */
11function dispatchKey(
12 key: string,
13 options: { eventType?: 'keydown' | 'keyup' } = {},
14): KeyboardEvent {
15 const eventType = options.eventType ?? 'keydown'
16 const event = new KeyboardEvent(eventType, { key, bubbles: true })
17 document.dispatchEvent(event)
18 return event
19}
20
21/**
22 * Helper to dispatch a keyboard event from a specific element.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…