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

Function normalizeKeyName

packages/hotkeys/src/constants.ts:457–481  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

455 * ```
456 */
457export function normalizeKeyName(key: string): string {
458 // key can be undefined in rare cases
459 // (browser extensions synthesizing key events, accessibility tools, certain OS/browser combinations).
460 if (!key) return ''
461 // Check aliases first
462 if (key in KEY_ALIASES) {
463 return KEY_ALIASES[key]!
464 }
465
466 if (isSingleLetterKey(key)) {
467 const upper = key.toUpperCase()
468 // Some Unicode letters (e.g., 'ß') uppercase to multi-character sequences
469 // ('SS'). Avoid changing the string length so the rest of the matching
470 // logic can rely on a stable single-character key value.
471 return upper.length === 1 ? upper : key
472 }
473
474 // Check if it's a function key (normalize case)
475 const upperKey = key.toUpperCase()
476 if (/^F([1-9]|1[0-2])$/.test(upperKey)) {
477 return upperKey
478 }
479
480 return key
481}
482
483// =============================================================================
484// Display Symbols

Callers 10

matchesKeyboardEventFunction · 0.90
parseHotkeyFunction · 0.90
parseKeyboardEventFunction · 0.90
#setupListenersMethod · 0.90
isKeyHeldMethod · 0.90
hotkeyChordFromKeydownFunction · 0.90
#processTargetEventMethod · 0.90
parse.test.tsFile · 0.90

Calls 1

isSingleLetterKeyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…