(key: number | string)
| 157 | } |
| 158 | |
| 159 | function 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 | |
| 178 | function normalizeStepMs(stepMs: number | undefined): number { |
| 179 | if (stepMs === undefined) return 1; |
no test coverage detected