feat: add type-safe KeyId for matchesKey function

- Add KeyId union type covering all valid key combinations
- Add Key helper object for autocomplete (Key.ctrl('c'), Key.escape, etc.)
- Update matchesKey signature to use KeyId instead of string
- Catches typos like 'esacpe' at compile time
This commit is contained in:
Helmut Januschka 2026-01-03 16:03:35 +01:00
parent f79256ac3b
commit 38b7f21e01
3 changed files with 123 additions and 9 deletions

View file

@ -1,4 +1,4 @@
import { matchesKey } from "./keys.js";
import { type KeyId, matchesKey } from "./keys.js";
/**
* Editor actions that can be bound to keys.
@ -31,10 +31,8 @@ export type EditorAction =
// Clipboard
| "copy";
/**
* Key identifier string (e.g., "ctrl+c", "shift+ctrl+p", "escape").
*/
export type KeyId = string;
// Re-export KeyId from keys.ts
export type { KeyId };
/**
* Editor keybindings configuration.