MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / charToKeyCode

Function charToKeyCode

packages/core/src/keybindings/keyCodes.ts:125–152  ·  view source on GitHub ↗
(char: string)

Source from the content-addressed store, hash-verified

123 * @returns Key code, or null if not a valid single-char key
124 */
125export function charToKeyCode(char: string): number | null {
126 if (char.length !== 1) return null;
127
128 const code = char.charCodeAt(0);
129
130 // Lowercase letters -> uppercase
131 if (code >= 97 && code <= 122) {
132 return code - 32; // 'a' (97) -> 'A' (65)
133 }
134
135 // Uppercase letters
136 if (code >= 65 && code <= 90) {
137 return code;
138 }
139
140 // Digits
141 if (code >= 48 && code <= 57) {
142 return code;
143 }
144
145 // Common punctuation/symbols (use ASCII directly)
146 // This includes: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
147 if (code >= 32 && code <= 126) {
148 return code;
149 }
150
151 return null;
152}
153
154/** Empty modifiers object (all false). */
155const MODS_BY_MASK: readonly Modifiers[] = (() => {

Callers 9

parseKeyPartFunction · 0.85
keyOfFunction · 0.85
keyOfFunction · 0.85
keyOfFunction · 0.85
normalizeKeyCodeFunction · 0.85
keyNameToCodeFunction · 0.85
keyNameToCodeFunction · 0.85
keyCodeFunction · 0.85

Calls

no outgoing calls

Tested by 4

keyOfFunction · 0.68
keyOfFunction · 0.68
keyOfFunction · 0.68
keyCodeFunction · 0.68