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

Function isKnownKey

packages/hotkeys/src/validate.ts:98–123  ·  view source on GitHub ↗

* Checks if a key is in the known keys set.

(key: string)

Source from the content-addressed store, hash-verified

96 * Checks if a key is in the known keys set.
97 */
98function isKnownKey(key: string): boolean {
99 // Check direct match
100 if (ALL_KEYS.has(key as any)) {
101 return true
102 }
103
104 // Check uppercase version for letters
105 if (key.length === 1 && ALL_KEYS.has(key.toUpperCase() as any)) {
106 return true
107 }
108
109 // Check common aliases
110 const aliases: Record<string, boolean> = {
111 Esc: true,
112 Return: true,
113 Space: true,
114 ' ': true,
115 Del: true,
116 Up: true,
117 Down: true,
118 Left: true,
119 Right: true,
120 }
121
122 return key in aliases
123}
124
125/**
126 * Validates a hotkey and throws an error if invalid.

Callers 1

validateHotkeyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…