(event: KeyboardEvent)
| 264 | * ``` |
| 265 | */ |
| 266 | export function parseKeyboardEvent(event: KeyboardEvent): ParsedHotkey { |
| 267 | const normalizedKey = normalizeKeyName(event.key) |
| 268 | |
| 269 | // Build modifiers array in canonical order |
| 270 | const modifiers: Array<CanonicalModifier> = [] |
| 271 | if (event.ctrlKey) modifiers.push('Control') |
| 272 | if (event.altKey) modifiers.push('Alt') |
| 273 | if (event.shiftKey) modifiers.push('Shift') |
| 274 | if (event.metaKey) modifiers.push('Meta') |
| 275 | |
| 276 | return { |
| 277 | key: normalizedKey, |
| 278 | ctrl: event.ctrlKey, |
| 279 | shift: event.shiftKey, |
| 280 | alt: event.altKey, |
| 281 | meta: event.metaKey, |
| 282 | modifiers, |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Normalizes a keyboard event to the same canonical hotkey string as {@link normalizeHotkey}. |
no test coverage detected
searching dependent graphs…