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

Function normalizeKeyCode

packages/core/src/testing/events.ts:159–176  ·  view source on GitHub ↗
(key: number | string)

Source from the content-addressed store, hash-verified

157}
158
159function normalizeKeyCode(key: number | string): number {
160 if (typeof key === "number") return toU32(key);
161
162 const trimmed = key.trim();
163 if (trimmed.length === 0) {
164 throw new Error("TestEventBuilder: key name must not be empty");
165 }
166
167 const direct = KEY_NAME_TO_CODE.get(trimmed.toLowerCase());
168 if (direct !== undefined) return direct;
169
170 if (trimmed.length === 1) {
171 const fromChar = charToKeyCode(trimmed);
172 if (fromChar !== null) return fromChar;
173 }
174
175 throw new Error(`TestEventBuilder: unsupported key "${key}"`);
176}
177
178function normalizeStepMs(stepMs: number | undefined): number {
179 if (stepMs === undefined) return 1;

Callers 1

addMethod · 0.85

Calls 3

toU32Function · 0.85
charToKeyCodeFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected