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

Function parseKeyboardEvent

packages/hotkeys/src/parse.ts:266–284  ·  view source on GitHub ↗
(event: KeyboardEvent)

Source from the content-addressed store, hash-verified

264 * ```
265 */
266export function parseKeyboardEvent(event: KeyboardEvent): ParsedHotkey {
267 const normalizedKey = normalizeKeyName(event.key)
268
269 // Build modifiers array in canonical order
270 const modifiers: Array<CanonicalModifier> = []
271 if (event.ctrlKey) modifiers.push('Control')
272 if (event.altKey) modifiers.push('Alt')
273 if (event.shiftKey) modifiers.push('Shift')
274 if (event.metaKey) modifiers.push('Meta')
275
276 return {
277 key: normalizedKey,
278 ctrl: event.ctrlKey,
279 shift: event.shiftKey,
280 alt: event.altKey,
281 meta: event.metaKey,
282 modifiers,
283 }
284}
285
286/**
287 * Normalizes a keyboard event to the same canonical hotkey string as {@link normalizeHotkey}.

Callers 1

normalizeHotkeyFromEventFunction · 0.85

Calls 1

normalizeKeyNameFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…