| 59 | // 'f9') that getKeyName() didn't handle, so modifier combos and f-keys |
| 60 | // silently failed to match after the onKeyDown migration (#23524). |
| 61 | function matchesKeyboardEvent(e: KeyboardEvent, target: ParsedKeystroke): boolean { |
| 62 | // KeyboardEvent stores key names; ParsedKeystroke stores ' ' for space |
| 63 | // and 'enter' for return (see parser.ts case 'space'/'return'). |
| 64 | const key = e.key === 'space' ? ' ' : e.key === 'return' ? 'enter' : e.key.toLowerCase(); |
| 65 | if (key !== target.key) return false; |
| 66 | if (e.ctrl !== target.ctrl) return false; |
| 67 | if (e.shift !== target.shift) return false; |
| 68 | // KeyboardEvent.meta folds alt|option (terminal limitation — esc-prefix); |
| 69 | // ParsedKeystroke has both alt and meta as aliases for the same thing. |
| 70 | if (e.meta !== (target.alt || target.meta)) return false; |
| 71 | if (e.superKey !== target.super) return false; |
| 72 | return true; |
| 73 | } |
| 74 | |
| 75 | // Hardcoded default for when there's no KeybindingProvider at all (e.g. |
| 76 | // headless/test contexts). NOT used when the provider exists and the |