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

Function dispatchKey

packages/hotkeys/tests/key-state-tracker.test.ts:8–20  ·  view source on GitHub ↗

* Helper to create and dispatch a KeyboardEvent

(
  type: 'keydown' | 'keyup',
  key: string,
  code?: string,
)

Source from the content-addressed store, hash-verified

6 * Helper to create and dispatch a KeyboardEvent
7 */
8function dispatchKey(
9 type: 'keydown' | 'keyup',
10 key: string,
11 code?: string,
12): KeyboardEvent {
13 const event = new KeyboardEvent(type, {
14 key,
15 code: code ?? key,
16 bubbles: true,
17 })
18 document.dispatchEvent(event)
19 return event
20}
21
22describe('KeyStateTracker', () => {
23 beforeEach(() => {

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…