@tanstack/hotkeys 0.4.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +1 -1
  2. package/dist/constants.cjs +70 -10
  3. package/dist/constants.cjs.map +1 -1
  4. package/dist/constants.d.cts +57 -4
  5. package/dist/constants.d.ts +57 -4
  6. package/dist/constants.js +67 -10
  7. package/dist/constants.js.map +1 -1
  8. package/dist/format.cjs +20 -125
  9. package/dist/format.cjs.map +1 -1
  10. package/dist/format.d.cts +8 -72
  11. package/dist/format.d.ts +8 -72
  12. package/dist/format.js +23 -127
  13. package/dist/format.js.map +1 -1
  14. package/dist/hotkey-manager.cjs.map +1 -1
  15. package/dist/hotkey-manager.d.cts +5 -1
  16. package/dist/hotkey-manager.d.ts +5 -1
  17. package/dist/hotkey-manager.js.map +1 -1
  18. package/dist/{recorder.cjs → hotkey-recorder.cjs} +14 -16
  19. package/dist/hotkey-recorder.cjs.map +1 -0
  20. package/dist/{recorder.d.cts → hotkey-recorder.d.cts} +2 -2
  21. package/dist/{recorder.d.ts → hotkey-recorder.d.ts} +2 -2
  22. package/dist/{recorder.js → hotkey-recorder.js} +14 -16
  23. package/dist/hotkey-recorder.js.map +1 -0
  24. package/dist/hotkey-sequence-recorder.cjs +188 -0
  25. package/dist/hotkey-sequence-recorder.cjs.map +1 -0
  26. package/dist/hotkey-sequence-recorder.d.cts +71 -0
  27. package/dist/hotkey-sequence-recorder.d.ts +71 -0
  28. package/dist/hotkey-sequence-recorder.js +188 -0
  29. package/dist/hotkey-sequence-recorder.js.map +1 -0
  30. package/dist/hotkey.d.cts +2 -0
  31. package/dist/hotkey.d.ts +2 -0
  32. package/dist/index.cjs +12 -7
  33. package/dist/index.d.cts +7 -6
  34. package/dist/index.d.ts +7 -6
  35. package/dist/index.js +7 -6
  36. package/dist/parse.cjs +53 -91
  37. package/dist/parse.cjs.map +1 -1
  38. package/dist/parse.d.cts +31 -72
  39. package/dist/parse.d.ts +31 -72
  40. package/dist/parse.js +51 -89
  41. package/dist/parse.js.map +1 -1
  42. package/dist/recorder-chord.cjs +18 -0
  43. package/dist/recorder-chord.cjs.map +1 -0
  44. package/dist/recorder-chord.js +18 -0
  45. package/dist/recorder-chord.js.map +1 -0
  46. package/dist/sequence-manager.cjs +24 -8
  47. package/dist/sequence-manager.cjs.map +1 -1
  48. package/dist/sequence-manager.d.cts +11 -2
  49. package/dist/sequence-manager.d.ts +11 -2
  50. package/dist/sequence-manager.js +25 -10
  51. package/dist/sequence-manager.js.map +1 -1
  52. package/package.json +1 -1
  53. package/src/constants.ts +75 -21
  54. package/src/format.ts +58 -196
  55. package/src/hotkey-manager.ts +5 -1
  56. package/src/{recorder.ts → hotkey-recorder.ts} +18 -32
  57. package/src/hotkey-sequence-recorder.ts +308 -0
  58. package/src/hotkey.ts +2 -0
  59. package/src/index.ts +2 -1
  60. package/src/parse.ts +91 -131
  61. package/src/recorder-chord.ts +25 -0
  62. package/src/sequence-manager.ts +30 -9
  63. package/dist/recorder.cjs.map +0 -1
  64. package/dist/recorder.js.map +0 -1
package/README.md CHANGED
@@ -37,7 +37,7 @@
37
37
  # TanStack Hotkeys
38
38
 
39
39
  > [!NOTE]
40
- > TanStack Hotkeys is pre-alpha (prototyping phase). We are actively developing the library and are open to feedback and contributions.
40
+ > TanStack Hotkeys is alpha. We are actively developing the library and are open to feedback and contributions.
41
41
 
42
42
  Type-safe keyboard shortcuts for the web. Template-string bindings, parsed objects, a cross-platform `Mod` key, a singleton Hotkey Manager, and utilities for cheatsheet UIs—built to stay SSR-friendly.
43
43
 
@@ -87,6 +87,10 @@ const MODIFIER_ALIASES = {
87
87
  command: "Meta",
88
88
  cmd: "Meta",
89
89
  meta: "Meta",
90
+ OS: "Meta",
91
+ os: "Meta",
92
+ Win: "Meta",
93
+ win: "Meta",
90
94
  CommandOrControl: "Mod",
91
95
  Mod: "Mod",
92
96
  commandorcontrol: "Mod",
@@ -256,16 +260,16 @@ const PUNCTUATION_KEYS = new Set([
256
260
  * fallbacks for letters and digits.
257
261
  */
258
262
  const PUNCTUATION_CODE_MAP = {
259
- Minus: "-",
260
- Equal: "=",
261
- Slash: "/",
263
+ Backquote: "`",
264
+ Backslash: "\\",
262
265
  BracketLeft: "[",
263
266
  BracketRight: "]",
264
- Backslash: "\\",
265
267
  Comma: ",",
268
+ Equal: "=",
269
+ Minus: "-",
266
270
  Period: ".",
267
- Backquote: "`",
268
- Semicolon: ";"
271
+ Semicolon: ";",
272
+ Slash: "/"
269
273
  };
270
274
  /**
271
275
  * Set of all valid non-modifier keys.
@@ -372,6 +376,20 @@ const KEY_ALIASES = {
372
376
  function isSingleLetterKey(key) {
373
377
  return /^\p{Letter}$/u.test(key);
374
378
  }
379
+ /**
380
+ * Normalizes a key name to its canonical form.
381
+ *
382
+ * @param key - The key name to normalize (can be an alias, lowercase, etc.)
383
+ * @returns The canonical key name
384
+ *
385
+ * @example
386
+ * ```ts
387
+ * normalizeKeyName('esc') // 'Escape'
388
+ * normalizeKeyName('a') // 'A'
389
+ * normalizeKeyName('f1') // 'F1'
390
+ * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)
391
+ * ```
392
+ */
375
393
  function normalizeKeyName(key) {
376
394
  if (key in KEY_ALIASES) return KEY_ALIASES[key];
377
395
  if (isSingleLetterKey(key)) {
@@ -401,7 +419,30 @@ const MAC_MODIFIER_SYMBOLS = {
401
419
  Control: "⌃",
402
420
  Alt: "⌥",
403
421
  Shift: "⇧",
404
- Meta: "⌘"
422
+ Meta: "⌘",
423
+ Mod: "⌘"
424
+ };
425
+ /**
426
+ * Modifier key labels for macOS display.
427
+ *
428
+ * Used by formatting functions to display hotkeys with macOS-style text labels
429
+ * (e.g., 'Control' for Control, 'Option' for Alt, 'Cmd' for Meta) instead of symbols.
430
+ * This provides a familiar macOS look and feel in hotkey displays.
431
+ *
432
+ * @example
433
+ * ```ts
434
+ * MAC_MODIFIER_LABELS['Control'] // 'control'
435
+ * MAC_MODIFIER_LABELS['Alt'] // 'option'
436
+ * MAC_MODIFIER_LABELS['Shift'] // 'shift'
437
+ * MAC_MODIFIER_LABELS['Meta'] // 'cmd'
438
+ * ```
439
+ */
440
+ const MAC_MODIFIER_LABELS = {
441
+ Control: "Control",
442
+ Alt: "Option",
443
+ Shift: "Shift",
444
+ Meta: "Cmd",
445
+ Mod: "Cmd"
405
446
  };
406
447
  /**
407
448
  * Modifier key labels for Windows/Linux display.
@@ -418,11 +459,27 @@ const MAC_MODIFIER_SYMBOLS = {
418
459
  * STANDARD_MODIFIER_LABELS['Shift'] // 'Shift'
419
460
  * ```
420
461
  */
421
- const STANDARD_MODIFIER_LABELS = {
462
+ const WINDOWS_MODIFIER_LABELS = {
422
463
  Control: "Ctrl",
423
464
  Alt: "Alt",
424
465
  Shift: "Shift",
425
- Meta: "Win"
466
+ Meta: "Win",
467
+ Mod: "Ctrl"
468
+ };
469
+ const LINUX_MODIFIER_LABELS = {
470
+ ...WINDOWS_MODIFIER_LABELS,
471
+ Meta: "Super"
472
+ };
473
+ const PUNCTUATION_KEY_DISPLAY_LABELS = {
474
+ "`": "Backquote",
475
+ "\\": "Backslash",
476
+ "[": "Left Bracket",
477
+ "]": "Right Bracket",
478
+ ",": "Comma",
479
+ "=": "Equal",
480
+ "-": "Minus",
481
+ ".": "Period",
482
+ ";": "Semicolon"
426
483
  };
427
484
  /**
428
485
  * Special key symbols for display formatting.
@@ -458,6 +515,8 @@ exports.EDITING_KEYS = EDITING_KEYS;
458
515
  exports.FUNCTION_KEYS = FUNCTION_KEYS;
459
516
  exports.KEY_DISPLAY_SYMBOLS = KEY_DISPLAY_SYMBOLS;
460
517
  exports.LETTER_KEYS = LETTER_KEYS;
518
+ exports.LINUX_MODIFIER_LABELS = LINUX_MODIFIER_LABELS;
519
+ exports.MAC_MODIFIER_LABELS = MAC_MODIFIER_LABELS;
461
520
  exports.MAC_MODIFIER_SYMBOLS = MAC_MODIFIER_SYMBOLS;
462
521
  exports.MODIFIER_ALIASES = MODIFIER_ALIASES;
463
522
  exports.MODIFIER_KEYS = MODIFIER_KEYS;
@@ -466,7 +525,8 @@ exports.NAVIGATION_KEYS = NAVIGATION_KEYS;
466
525
  exports.NUMBER_KEYS = NUMBER_KEYS;
467
526
  exports.PUNCTUATION_CODE_MAP = PUNCTUATION_CODE_MAP;
468
527
  exports.PUNCTUATION_KEYS = PUNCTUATION_KEYS;
469
- exports.STANDARD_MODIFIER_LABELS = STANDARD_MODIFIER_LABELS;
528
+ exports.PUNCTUATION_KEY_DISPLAY_LABELS = PUNCTUATION_KEY_DISPLAY_LABELS;
529
+ exports.WINDOWS_MODIFIER_LABELS = WINDOWS_MODIFIER_LABELS;
470
530
  exports.detectPlatform = detectPlatform;
471
531
  exports.isSingleLetterKey = isSingleLetterKey;
472
532
  exports.normalizeKeyName = normalizeKeyName;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type {\n CanonicalModifier,\n EditingKey,\n FunctionKey,\n LetterKey,\n NavigationKey,\n NumberKey,\n PunctuationKey,\n} from './hotkey'\n\n// =============================================================================\n// Platform Detection\n// =============================================================================\n\n/**\n * Detects the current platform based on browser navigator properties.\n *\n * Used internally to resolve platform-adaptive modifiers like 'Mod' (Command on Mac,\n * Control elsewhere) and for platform-specific hotkey formatting.\n *\n * @returns The detected platform: 'mac', 'windows', or 'linux'\n * @remarks Defaults to 'linux' in SSR environments where navigator is undefined\n *\n * @example\n * ```ts\n * const platform = detectPlatform() // 'mac' | 'windows' | 'linux'\n * const modifier = resolveModifier('Mod', platform) // 'Meta' on Mac, 'Control' elsewhere\n * ```\n */\nexport function detectPlatform(): 'mac' | 'windows' | 'linux' {\n if (typeof navigator === 'undefined') {\n return 'linux' // Default for SSR\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const platform = navigator.platform?.toLowerCase() ?? ''\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const userAgent = navigator.userAgent?.toLowerCase() ?? ''\n\n if (platform.includes('mac') || userAgent.includes('mac')) {\n return 'mac'\n }\n if (platform.includes('win') || userAgent.includes('win')) {\n return 'windows'\n }\n return 'linux'\n}\n\n// =============================================================================\n// Modifier Aliases\n// =============================================================================\n\n/**\n * Canonical order for modifiers in normalized hotkey strings.\n *\n * Defines the standard order in which modifiers should appear when formatting\n * hotkeys. This ensures consistent, predictable output across the library.\n *\n * Order: Control → Alt → Shift → Meta\n *\n * @example\n * ```ts\n * // Input: 'Shift+Control+Meta+S'\n * // Normalized: 'Control+Alt+Shift+Meta+S' (following MODIFIER_ORDER)\n * ```\n */\nexport const MODIFIER_ORDER: Array<CanonicalModifier> = [\n 'Control',\n 'Alt',\n 'Shift',\n 'Meta',\n]\n\n/**\n * Set of canonical modifier key names for fast lookup.\n *\n * Derived from `MODIFIER_ORDER` to ensure consistency. Used to detect when\n * a modifier is released so we can clear non-modifier keys whose keyup events\n * may have been swallowed by the OS (e.g. macOS Cmd+key combos).\n */\nexport const MODIFIER_KEYS = new Set<string>(MODIFIER_ORDER)\n\n/**\n * Maps modifier key aliases to their canonical form or platform-adaptive 'Mod'.\n *\n * This map allows users to write hotkeys using various aliases (e.g., 'Ctrl', 'Cmd', 'Option')\n * which are then normalized to canonical names ('Control', 'Meta', 'Alt') or the\n * platform-adaptive 'Mod' token.\n *\n * The 'Mod' and 'CommandOrControl' aliases are resolved at runtime via `resolveModifier()`\n * based on the detected platform (Command on Mac, Control elsewhere).\n *\n * @remarks Case-insensitive lookups are supported via lowercase variants\n *\n * @example\n * ```ts\n * MODIFIER_ALIASES['Ctrl'] // 'Control'\n * MODIFIER_ALIASES['Cmd'] // 'Meta'\n * MODIFIER_ALIASES['Mod'] // 'Mod' (resolved at runtime)\n * ```\n */\nexport const MODIFIER_ALIASES: Record<string, CanonicalModifier | 'Mod'> = {\n // Control variants\n Control: 'Control',\n Ctrl: 'Control',\n control: 'Control',\n ctrl: 'Control',\n\n // Shift variants\n Shift: 'Shift',\n shift: 'Shift',\n\n // Alt variants\n Alt: 'Alt',\n Option: 'Alt',\n alt: 'Alt',\n option: 'Alt',\n\n // Meta/Command variants\n Command: 'Meta',\n Cmd: 'Meta',\n Meta: 'Meta',\n command: 'Meta',\n cmd: 'Meta',\n meta: 'Meta',\n\n // Platform-adaptive (resolved at runtime)\n CommandOrControl: 'Mod',\n Mod: 'Mod',\n commandorcontrol: 'Mod',\n mod: 'Mod',\n}\n\n/**\n * Resolves the platform-adaptive 'Mod' modifier to the appropriate canonical modifier.\n *\n * The 'Mod' token represents the \"primary modifier\" on each platform:\n * - macOS: 'Meta' (Command key ⌘)\n * - Windows/Linux: 'Control' (Ctrl key)\n *\n * This enables cross-platform hotkey definitions like 'Mod+S' that automatically\n * map to Command+S on Mac and Ctrl+S on Windows/Linux.\n *\n * @param modifier - The modifier to resolve. If 'Mod', resolves based on platform.\n * @param platform - The target platform. Defaults to auto-detection.\n * @returns The canonical modifier name ('Control', 'Shift', 'Alt', or 'Meta')\n *\n * @example\n * ```ts\n * resolveModifier('Mod', 'mac') // 'Meta'\n * resolveModifier('Mod', 'windows') // 'Control'\n * resolveModifier('Control', 'mac') // 'Control' (unchanged)\n * ```\n */\nexport function resolveModifier(\n modifier: CanonicalModifier | 'Mod',\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): CanonicalModifier {\n if (modifier === 'Mod') {\n return platform === 'mac' ? 'Meta' : 'Control'\n }\n return modifier\n}\n\n// =============================================================================\n// Valid Keys\n// =============================================================================\n\n/**\n * Set of all valid letter keys (A-Z).\n *\n * Used for validation and type checking. Letter keys are matched case-insensitively\n * in hotkey matching, but normalized to uppercase in canonical form.\n */\nexport const LETTER_KEYS = new Set<LetterKey>([\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'I',\n 'J',\n 'K',\n 'L',\n 'M',\n 'N',\n 'O',\n 'P',\n 'Q',\n 'R',\n 'S',\n 'T',\n 'U',\n 'V',\n 'W',\n 'X',\n 'Y',\n 'Z',\n])\n\n/**\n * Set of all valid number keys (0-9).\n *\n * Note: Number keys are affected by Shift (Shift+1 → '!' on US layout),\n * so they're excluded from Shift-based hotkey combinations to avoid\n * layout-dependent behavior.\n */\nexport const NUMBER_KEYS = new Set<NumberKey>([\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n])\n\n/**\n * Set of all valid function keys (F1-F12).\n *\n * Function keys are commonly used for system shortcuts (e.g., F12 for DevTools,\n * Alt+F4 to close windows) and application-specific commands.\n */\nexport const FUNCTION_KEYS = new Set<FunctionKey>([\n 'F1',\n 'F2',\n 'F3',\n 'F4',\n 'F5',\n 'F6',\n 'F7',\n 'F8',\n 'F9',\n 'F10',\n 'F11',\n 'F12',\n])\n\n/**\n * Set of all valid navigation keys for cursor movement and document navigation.\n *\n * Includes arrow keys, Home/End (line navigation), and PageUp/PageDown (page navigation).\n * These keys are commonly combined with modifiers for selection (Shift+ArrowUp) or\n * navigation shortcuts (Alt+ArrowLeft for back).\n */\nexport const NAVIGATION_KEYS = new Set<NavigationKey>([\n 'ArrowUp',\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n])\n\n/**\n * Set of all valid editing and special keys.\n *\n * Includes keys commonly used for text editing (Enter, Backspace, Delete, Tab) and\n * special actions (Escape, Space). These keys are frequently combined with modifiers\n * for editor shortcuts (Mod+Enter to submit, Shift+Tab to go back).\n */\nexport const EDITING_KEYS = new Set<EditingKey>([\n 'Enter',\n 'Escape',\n 'Space',\n 'Tab',\n 'Backspace',\n 'Delete',\n])\n\n/**\n * Set of all valid punctuation keys commonly used in keyboard shortcuts.\n *\n * These are the literal characters as they appear in `KeyboardEvent.key` (layout-dependent,\n * typically US keyboard layout). Common shortcuts include:\n * - `Mod+/` - Toggle comment\n * - `Mod+[` / `Mod+]` - Indent/outdent\n * - `Mod+=` / `Mod+-` - Zoom in/out\n *\n * Note: Punctuation keys are affected by Shift (Shift+',' → '<' on US layout),\n * so they're excluded from Shift-based hotkey combinations to avoid layout-dependent behavior.\n */\nexport const PUNCTUATION_KEYS = new Set<PunctuationKey>([\n '/',\n '[',\n ']',\n '\\\\',\n '=',\n '-',\n ',',\n '.',\n ';',\n '`',\n])\n\n/**\n * Maps `KeyboardEvent.code` values for punctuation keys to their canonical characters.\n *\n * On macOS, holding the Option (Alt) key transforms punctuation keys into special characters\n * (e.g., Option+Minus → en-dash '–'), causing `event.key` to differ from the expected character.\n * However, `event.code` still reports the physical key (e.g., 'Minus'). This map enables\n * falling back to `event.code` for punctuation keys, similar to the existing `Key*`/`Digit*`\n * fallbacks for letters and digits.\n */\nexport const PUNCTUATION_CODE_MAP: Record<string, string> = {\n Minus: '-',\n Equal: '=',\n Slash: '/',\n BracketLeft: '[',\n BracketRight: ']',\n Backslash: '\\\\',\n Comma: ',',\n Period: '.',\n Backquote: '`',\n Semicolon: ';',\n}\n\n/**\n * Set of all valid non-modifier keys.\n *\n * This is the union of all key type sets (letters, numbers, function keys, navigation,\n * editing, and punctuation). Used primarily for validation to check if a key string\n * is recognized and will have type-safe autocomplete support.\n *\n * @see {@link LETTER_KEYS}\n * @see {@link NUMBER_KEYS}\n * @see {@link FUNCTION_KEYS}\n * @see {@link NAVIGATION_KEYS}\n * @see {@link EDITING_KEYS}\n * @see {@link PUNCTUATION_KEYS}\n */\nexport const ALL_KEYS = new Set([\n ...LETTER_KEYS,\n ...NUMBER_KEYS,\n ...FUNCTION_KEYS,\n ...NAVIGATION_KEYS,\n ...EDITING_KEYS,\n ...PUNCTUATION_KEYS,\n])\n\n/**\n * Maps key name aliases to their canonical form.\n *\n * Handles common variations and alternative names for keys to provide a more\n * forgiving API. For example, users can write 'Esc', 'esc', or 'escape' and\n * they'll all normalize to 'Escape'.\n *\n * This map is used internally by `normalizeKeyName()` to convert user input\n * into the canonical key names used throughout the library.\n *\n * @remarks Case-insensitive lookups are supported via lowercase variants\n *\n * @example\n * ```ts\n * KEY_ALIASES['Esc'] // 'Escape'\n * KEY_ALIASES['Del'] // 'Delete'\n * KEY_ALIASES['Up'] // 'ArrowUp'\n * ```\n */\nconst KEY_ALIASES: Record<string, string> = {\n // Escape variants\n Esc: 'Escape',\n esc: 'Escape',\n escape: 'Escape',\n\n // Enter variants\n Return: 'Enter',\n return: 'Enter',\n enter: 'Enter',\n\n // Space variants\n ' ': 'Space',\n space: 'Space',\n Spacebar: 'Space',\n spacebar: 'Space',\n\n // Tab variants\n tab: 'Tab',\n\n // Backspace variants\n backspace: 'Backspace',\n\n // Delete variants\n Del: 'Delete',\n del: 'Delete',\n delete: 'Delete',\n\n // Arrow key variants\n Up: 'ArrowUp',\n up: 'ArrowUp',\n arrowup: 'ArrowUp',\n Down: 'ArrowDown',\n down: 'ArrowDown',\n arrowdown: 'ArrowDown',\n Left: 'ArrowLeft',\n left: 'ArrowLeft',\n arrowleft: 'ArrowLeft',\n Right: 'ArrowRight',\n right: 'ArrowRight',\n arrowright: 'ArrowRight',\n\n // Navigation variants\n home: 'Home',\n end: 'End',\n pageup: 'PageUp',\n pagedown: 'PageDown',\n PgUp: 'PageUp',\n PgDn: 'PageDown',\n pgup: 'PageUp',\n pgdn: 'PageDown',\n}\n\n/**\n * Normalizes a key name to its canonical form.\n *\n * Converts various key name formats (aliases, case variations) into the standard\n * canonical names used throughout the library. This enables a more forgiving API\n * where users can write keys in different ways and still get correct behavior.\n *\n * Normalization rules:\n * 1. Check aliases first (e.g., 'Esc' → 'Escape', 'Del' → 'Delete')\n * 2. Single letters → uppercase (e.g., 'a' → 'A', 's' → 'S')\n * 3. Function keys → uppercase (e.g., 'f1' → 'F1', 'F12' → 'F12')\n * 4. Other keys → returned as-is (already canonical or unknown)\n *\n * @param key - The key name to normalize (can be an alias, lowercase, etc.)\n * @returns The canonical key name\n *\n * @example\n * ```ts\n * normalizeKeyName('esc') // 'Escape'\n * normalizeKeyName('a') // 'A'\n * normalizeKeyName('f1') // 'F1'\n * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)\n * ```\n */\nexport function isSingleLetterKey(key: string): boolean {\n return /^\\p{Letter}$/u.test(key)\n}\n\nexport function normalizeKeyName(key: string): string {\n // Check aliases first\n if (key in KEY_ALIASES) {\n return KEY_ALIASES[key]!\n }\n\n if (isSingleLetterKey(key)) {\n const upper = key.toUpperCase()\n // Some Unicode letters (e.g., 'ß') uppercase to multi-character sequences\n // ('SS'). Avoid changing the string length so the rest of the matching\n // logic can rely on a stable single-character key value.\n return upper.length === 1 ? upper : key\n }\n\n // Check if it's a function key (normalize case)\n const upperKey = key.toUpperCase()\n if (/^F([1-9]|1[0-2])$/.test(upperKey)) {\n return upperKey\n }\n\n return key\n}\n\n// =============================================================================\n// Display Symbols\n// =============================================================================\n\n/**\n * Modifier key symbols for macOS display.\n *\n * Used by formatting functions to display hotkeys with macOS-style symbols\n * (e.g., ⌘ for Command, ⌃ for Control) instead of text labels. This provides\n * a native macOS look and feel in hotkey displays.\n *\n * @example\n * ```ts\n * MAC_MODIFIER_SYMBOLS['Meta'] // '⌘'\n * MAC_MODIFIER_SYMBOLS['Control'] // '⌃'\n * MAC_MODIFIER_SYMBOLS['Alt'] // '⌥'\n * MAC_MODIFIER_SYMBOLS['Shift'] // '⇧'\n * ```\n */\nexport const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier, string> = {\n Control: '⌃',\n Alt: '⌥',\n Shift: '⇧',\n Meta: '⌘',\n}\n\n/**\n * Modifier key labels for Windows/Linux display.\n *\n * Used by formatting functions to display hotkeys with standard text labels\n * (e.g., 'Ctrl' for Control, 'Win' for Meta/Windows key) instead of symbols.\n * This provides a familiar Windows/Linux look and feel in hotkey displays.\n *\n * @example\n * ```ts\n * STANDARD_MODIFIER_LABELS['Control'] // 'Ctrl'\n * STANDARD_MODIFIER_LABELS['Meta'] // 'Win'\n * STANDARD_MODIFIER_LABELS['Alt'] // 'Alt'\n * STANDARD_MODIFIER_LABELS['Shift'] // 'Shift'\n * ```\n */\nexport const STANDARD_MODIFIER_LABELS: Record<CanonicalModifier, string> = {\n Control: 'Ctrl',\n Alt: 'Alt',\n Shift: 'Shift',\n Meta: 'Win',\n}\n\n/**\n * Special key symbols for display formatting.\n *\n * Maps certain keys to their visual symbols for better readability in hotkey displays.\n * Used by formatting functions to show symbols like ↑ for ArrowUp or ↵ for Enter\n * instead of text labels.\n *\n * @example\n * ```ts\n * KEY_DISPLAY_SYMBOLS['ArrowUp'] // '↑'\n * KEY_DISPLAY_SYMBOLS['Enter'] // '↵'\n * KEY_DISPLAY_SYMBOLS['Escape'] // 'Esc'\n * KEY_DISPLAY_SYMBOLS['Space'] // '␣'\n * ```\n */\nexport const KEY_DISPLAY_SYMBOLS: Record<string, string> = {\n ArrowUp: '↑',\n ArrowDown: '↓',\n ArrowLeft: '←',\n ArrowRight: '→',\n Enter: '↵',\n Escape: 'Esc',\n Backspace: '⌫',\n Delete: '⌦',\n Tab: '⇥',\n Space: '␣',\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"constants.cjs","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import type {\n CanonicalModifier,\n EditingKey,\n FunctionKey,\n LetterKey,\n NavigationKey,\n NumberKey,\n PunctuationKey,\n} from './hotkey'\n\n/**\n * Detects the current platform based on browser navigator properties.\n *\n * Used internally to resolve platform-adaptive modifiers like 'Mod' (Command on Mac,\n * Control elsewhere) and for platform-specific hotkey formatting.\n *\n * @returns The detected platform: 'mac', 'windows', or 'linux'\n * @remarks Defaults to 'linux' in SSR environments where navigator is undefined\n *\n * @example\n * ```ts\n * const platform = detectPlatform() // 'mac' | 'windows' | 'linux'\n * const modifier = resolveModifier('Mod', platform) // 'Meta' on Mac, 'Control' elsewhere\n * ```\n */\nexport function detectPlatform(): 'mac' | 'windows' | 'linux' {\n if (typeof navigator === 'undefined') {\n return 'linux' // Default for SSR\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const platform = navigator.platform?.toLowerCase() ?? ''\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const userAgent = navigator.userAgent?.toLowerCase() ?? ''\n\n if (platform.includes('mac') || userAgent.includes('mac')) {\n return 'mac'\n }\n if (platform.includes('win') || userAgent.includes('win')) {\n return 'windows'\n }\n return 'linux'\n}\n\n/**\n * Canonical order for modifiers in normalized hotkey strings.\n *\n * Defines the standard order in which modifiers should appear when formatting\n * hotkeys. This ensures consistent, predictable output across the library.\n *\n * Order: Control → Alt → Shift → Meta\n *\n * @example\n * ```ts\n * // Input: 'Shift+Control+Meta+S'\n * // Normalized: 'Control+Alt+Shift+Meta+S' (following MODIFIER_ORDER)\n * ```\n */\nexport const MODIFIER_ORDER: Array<CanonicalModifier> = [\n 'Control',\n 'Alt',\n 'Shift',\n 'Meta',\n]\n\n/**\n * Set of canonical modifier key names for fast lookup.\n *\n * Derived from `MODIFIER_ORDER` to ensure consistency. Used to detect when\n * a modifier is released so we can clear non-modifier keys whose keyup events\n * may have been swallowed by the OS (e.g. macOS Cmd+key combos).\n */\nexport const MODIFIER_KEYS = new Set<string>(MODIFIER_ORDER)\n\n/**\n * Maps modifier key aliases to their canonical form or platform-adaptive 'Mod'.\n *\n * This map allows users to write hotkeys using various aliases (e.g., 'Ctrl', 'Cmd', 'Option')\n * which are then normalized to canonical names ('Control', 'Meta', 'Alt') or the\n * platform-adaptive 'Mod' token.\n *\n * The 'Mod' and 'CommandOrControl' aliases are resolved at runtime via `resolveModifier()`\n * based on the detected platform (Command on Mac, Control elsewhere).\n *\n * @remarks Case-insensitive lookups are supported via lowercase variants\n *\n * @example\n * ```ts\n * MODIFIER_ALIASES['Ctrl'] // 'Control'\n * MODIFIER_ALIASES['Cmd'] // 'Meta'\n * MODIFIER_ALIASES['Mod'] // 'Mod' (resolved at runtime)\n * ```\n */\nexport const MODIFIER_ALIASES: Record<string, CanonicalModifier | 'Mod'> = {\n // Control variants\n Control: 'Control',\n Ctrl: 'Control',\n control: 'Control',\n ctrl: 'Control',\n\n // Shift variants\n Shift: 'Shift',\n shift: 'Shift',\n\n // Alt variants\n Alt: 'Alt',\n Option: 'Alt',\n alt: 'Alt',\n option: 'Alt',\n\n // Meta/Command variants\n Command: 'Meta',\n Cmd: 'Meta',\n Meta: 'Meta',\n command: 'Meta',\n cmd: 'Meta',\n meta: 'Meta',\n\n // DOM `KeyboardEvent.key` spellings for the meta / Windows key\n OS: 'Meta',\n os: 'Meta',\n Win: 'Meta',\n win: 'Meta',\n\n // Platform-adaptive (resolved at runtime)\n CommandOrControl: 'Mod',\n Mod: 'Mod',\n commandorcontrol: 'Mod',\n mod: 'Mod',\n}\n\n/**\n * Resolves the platform-adaptive 'Mod' modifier to the appropriate canonical modifier.\n *\n * The 'Mod' token represents the \"primary modifier\" on each platform:\n * - macOS: 'Meta' (Command key ⌘)\n * - Windows/Linux: 'Control' (Ctrl key)\n *\n * This enables cross-platform hotkey definitions like 'Mod+S' that automatically\n * map to Command+S on Mac and Ctrl+S on Windows/Linux.\n *\n * @param modifier - The modifier to resolve. If 'Mod', resolves based on platform.\n * @param platform - The target platform. Defaults to auto-detection.\n * @returns The canonical modifier name ('Control', 'Shift', 'Alt', or 'Meta')\n *\n * @example\n * ```ts\n * resolveModifier('Mod', 'mac') // 'Meta'\n * resolveModifier('Mod', 'windows') // 'Control'\n * resolveModifier('Control', 'mac') // 'Control' (unchanged)\n * ```\n */\nexport function resolveModifier(\n modifier: CanonicalModifier | 'Mod',\n platform: 'mac' | 'windows' | 'linux' = detectPlatform(),\n): CanonicalModifier {\n if (modifier === 'Mod') {\n return platform === 'mac' ? 'Meta' : 'Control'\n }\n return modifier\n}\n\n/**\n * Set of all valid letter keys (A-Z).\n *\n * Used for validation and type checking. Letter keys are matched case-insensitively\n * in hotkey matching, but normalized to uppercase in canonical form.\n */\nexport const LETTER_KEYS = new Set<LetterKey>([\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'I',\n 'J',\n 'K',\n 'L',\n 'M',\n 'N',\n 'O',\n 'P',\n 'Q',\n 'R',\n 'S',\n 'T',\n 'U',\n 'V',\n 'W',\n 'X',\n 'Y',\n 'Z',\n])\n\n/**\n * Set of all valid number keys (0-9).\n *\n * Note: Number keys are affected by Shift (Shift+1 → '!' on US layout),\n * so they're excluded from Shift-based hotkey combinations to avoid\n * layout-dependent behavior.\n */\nexport const NUMBER_KEYS = new Set<NumberKey>([\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n])\n\n/**\n * Set of all valid function keys (F1-F12).\n *\n * Function keys are commonly used for system shortcuts (e.g., F12 for DevTools,\n * Alt+F4 to close windows) and application-specific commands.\n */\nexport const FUNCTION_KEYS = new Set<FunctionKey>([\n 'F1',\n 'F2',\n 'F3',\n 'F4',\n 'F5',\n 'F6',\n 'F7',\n 'F8',\n 'F9',\n 'F10',\n 'F11',\n 'F12',\n])\n\n/**\n * Set of all valid navigation keys for cursor movement and document navigation.\n *\n * Includes arrow keys, Home/End (line navigation), and PageUp/PageDown (page navigation).\n * These keys are commonly combined with modifiers for selection (Shift+ArrowUp) or\n * navigation shortcuts (Alt+ArrowLeft for back).\n */\nexport const NAVIGATION_KEYS = new Set<NavigationKey>([\n 'ArrowUp',\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'Home',\n 'End',\n 'PageUp',\n 'PageDown',\n])\n\n/**\n * Set of all valid editing and special keys.\n *\n * Includes keys commonly used for text editing (Enter, Backspace, Delete, Tab) and\n * special actions (Escape, Space). These keys are frequently combined with modifiers\n * for editor shortcuts (Mod+Enter to submit, Shift+Tab to go back).\n */\nexport const EDITING_KEYS = new Set<EditingKey>([\n 'Enter',\n 'Escape',\n 'Space',\n 'Tab',\n 'Backspace',\n 'Delete',\n])\n\n/**\n * Set of all valid punctuation keys commonly used in keyboard shortcuts.\n *\n * These are the literal characters as they appear in `KeyboardEvent.key` (layout-dependent,\n * typically US keyboard layout). Common shortcuts include:\n * - `Mod+/` - Toggle comment\n * - `Mod+[` / `Mod+]` - Indent/outdent\n * - `Mod+=` / `Mod+-` - Zoom in/out\n *\n * Note: Punctuation keys are affected by Shift (Shift+',' → '<' on US layout),\n * so they're excluded from Shift-based hotkey combinations to avoid layout-dependent behavior.\n */\nexport const PUNCTUATION_KEYS = new Set<PunctuationKey>([\n '/',\n '[',\n ']',\n '\\\\',\n '=',\n '-',\n ',',\n '.',\n ';',\n '`',\n])\n\n/**\n * Maps `KeyboardEvent.code` values for punctuation keys to their canonical characters.\n *\n * On macOS, holding the Option (Alt) key transforms punctuation keys into special characters\n * (e.g., Option+Minus → en-dash '–'), causing `event.key` to differ from the expected character.\n * However, `event.code` still reports the physical key (e.g., 'Minus'). This map enables\n * falling back to `event.code` for punctuation keys, similar to the existing `Key*`/`Digit*`\n * fallbacks for letters and digits.\n */\nexport const PUNCTUATION_CODE_MAP: Record<string, string> = {\n Backquote: '`',\n Backslash: '\\\\',\n BracketLeft: '[',\n BracketRight: ']',\n Comma: ',',\n Equal: '=',\n Minus: '-',\n Period: '.',\n Semicolon: ';',\n Slash: '/',\n}\n\n/**\n * Set of all valid non-modifier keys.\n *\n * This is the union of all key type sets (letters, numbers, function keys, navigation,\n * editing, and punctuation). Used primarily for validation to check if a key string\n * is recognized and will have type-safe autocomplete support.\n *\n * @see {@link LETTER_KEYS}\n * @see {@link NUMBER_KEYS}\n * @see {@link FUNCTION_KEYS}\n * @see {@link NAVIGATION_KEYS}\n * @see {@link EDITING_KEYS}\n * @see {@link PUNCTUATION_KEYS}\n */\nexport const ALL_KEYS = new Set([\n ...LETTER_KEYS,\n ...NUMBER_KEYS,\n ...FUNCTION_KEYS,\n ...NAVIGATION_KEYS,\n ...EDITING_KEYS,\n ...PUNCTUATION_KEYS,\n])\n\n/**\n * Maps key name aliases to their canonical form.\n *\n * Handles common variations and alternative names for keys to provide a more\n * forgiving API. For example, users can write 'Esc', 'esc', or 'escape' and\n * they'll all normalize to 'Escape'.\n *\n * This map is used internally by `normalizeKeyName()` to convert user input\n * into the canonical key names used throughout the library.\n *\n * @remarks Case-insensitive lookups are supported via lowercase variants\n *\n * @example\n * ```ts\n * KEY_ALIASES['Esc'] // 'Escape'\n * KEY_ALIASES['Del'] // 'Delete'\n * KEY_ALIASES['Up'] // 'ArrowUp'\n * ```\n */\nconst KEY_ALIASES: Record<string, string> = {\n // Escape variants\n Esc: 'Escape',\n esc: 'Escape',\n escape: 'Escape',\n\n // Enter variants\n Return: 'Enter',\n return: 'Enter',\n enter: 'Enter',\n\n // Space variants\n ' ': 'Space',\n space: 'Space',\n Spacebar: 'Space',\n spacebar: 'Space',\n\n // Tab variants\n tab: 'Tab',\n\n // Backspace variants\n backspace: 'Backspace',\n\n // Delete variants\n Del: 'Delete',\n del: 'Delete',\n delete: 'Delete',\n\n // Arrow key variants\n Up: 'ArrowUp',\n up: 'ArrowUp',\n arrowup: 'ArrowUp',\n Down: 'ArrowDown',\n down: 'ArrowDown',\n arrowdown: 'ArrowDown',\n Left: 'ArrowLeft',\n left: 'ArrowLeft',\n arrowleft: 'ArrowLeft',\n Right: 'ArrowRight',\n right: 'ArrowRight',\n arrowright: 'ArrowRight',\n\n // Navigation variants\n home: 'Home',\n end: 'End',\n pageup: 'PageUp',\n pagedown: 'PageDown',\n PgUp: 'PageUp',\n PgDn: 'PageDown',\n pgup: 'PageUp',\n pgdn: 'PageDown',\n}\n\n/**\n * Normalizes a key name to its canonical form.\n *\n * Converts various key name formats (aliases, case variations) into the standard\n * canonical names used throughout the library. This enables a more forgiving API\n * where users can write keys in different ways and still get correct behavior.\n *\n * Normalization rules:\n * 1. Check aliases first (e.g., 'Esc' → 'Escape', 'Del' → 'Delete')\n * 2. Single letters → uppercase (e.g., 'a' → 'A', 's' → 'S')\n * 3. Function keys → uppercase (e.g., 'f1' → 'F1', 'F12' → 'F12')\n * 4. Other keys → returned as-is (already canonical or unknown)\n *\n * @param key - The key name to normalize (can be an alias, lowercase, etc.)\n * @returns The canonical key name\n *\n * @example\n * ```ts\n * normalizeKeyName('esc') // 'Escape'\n * normalizeKeyName('a') // 'A'\n * normalizeKeyName('f1') // 'F1'\n * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)\n * ```\n */\nexport function isSingleLetterKey(key: string): boolean {\n return /^\\p{Letter}$/u.test(key)\n}\n\n/**\n * Normalizes a key name to its canonical form.\n *\n * @param key - The key name to normalize (can be an alias, lowercase, etc.)\n * @returns The canonical key name\n *\n * @example\n * ```ts\n * normalizeKeyName('esc') // 'Escape'\n * normalizeKeyName('a') // 'A'\n * normalizeKeyName('f1') // 'F1'\n * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)\n * ```\n */\nexport function normalizeKeyName(key: string): string {\n // Check aliases first\n if (key in KEY_ALIASES) {\n return KEY_ALIASES[key]!\n }\n\n if (isSingleLetterKey(key)) {\n const upper = key.toUpperCase()\n // Some Unicode letters (e.g., 'ß') uppercase to multi-character sequences\n // ('SS'). Avoid changing the string length so the rest of the matching\n // logic can rely on a stable single-character key value.\n return upper.length === 1 ? upper : key\n }\n\n // Check if it's a function key (normalize case)\n const upperKey = key.toUpperCase()\n if (/^F([1-9]|1[0-2])$/.test(upperKey)) {\n return upperKey\n }\n\n return key\n}\n\n// =============================================================================\n// Display Symbols\n// =============================================================================\n\n/**\n * Modifier key symbols for macOS display.\n *\n * Used by formatting functions to display hotkeys with macOS-style symbols\n * (e.g., ⌘ for Command, ⌃ for Control) instead of text labels. This provides\n * a native macOS look and feel in hotkey displays.\n *\n * @example\n * ```ts\n * MAC_MODIFIER_SYMBOLS['Meta'] // '⌘'\n * MAC_MODIFIER_SYMBOLS['Control'] // '⌃'\n * MAC_MODIFIER_SYMBOLS['Alt'] // '⌥'\n * MAC_MODIFIER_SYMBOLS['Shift'] // '⇧'\n * ```\n */\nexport const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier | 'Mod', string> = {\n Control: '⌃',\n Alt: '⌥',\n Shift: '⇧',\n Meta: '⌘',\n Mod: '⌘',\n}\n\n/**\n * Modifier key labels for macOS display.\n *\n * Used by formatting functions to display hotkeys with macOS-style text labels\n * (e.g., 'Control' for Control, 'Option' for Alt, 'Cmd' for Meta) instead of symbols.\n * This provides a familiar macOS look and feel in hotkey displays.\n *\n * @example\n * ```ts\n * MAC_MODIFIER_LABELS['Control'] // 'control'\n * MAC_MODIFIER_LABELS['Alt'] // 'option'\n * MAC_MODIFIER_LABELS['Shift'] // 'shift'\n * MAC_MODIFIER_LABELS['Meta'] // 'cmd'\n * ```\n */\nexport const MAC_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string> = {\n Control: 'Control',\n Alt: 'Option',\n Shift: 'Shift',\n Meta: 'Cmd',\n Mod: 'Cmd',\n}\n\n/**\n * Modifier key labels for Windows/Linux display.\n *\n * Used by formatting functions to display hotkeys with standard text labels\n * (e.g., 'Ctrl' for Control, 'Win' for Meta/Windows key) instead of symbols.\n * This provides a familiar Windows/Linux look and feel in hotkey displays.\n *\n * @example\n * ```ts\n * STANDARD_MODIFIER_LABELS['Control'] // 'Ctrl'\n * STANDARD_MODIFIER_LABELS['Meta'] // 'Win'\n * STANDARD_MODIFIER_LABELS['Alt'] // 'Alt'\n * STANDARD_MODIFIER_LABELS['Shift'] // 'Shift'\n * ```\n */\nexport const WINDOWS_MODIFIER_LABELS: Record<\n CanonicalModifier | 'Mod',\n string\n> = {\n Control: 'Ctrl',\n Alt: 'Alt',\n Shift: 'Shift',\n Meta: 'Win',\n Mod: 'Ctrl',\n}\n\nexport const LINUX_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string> =\n {\n ...WINDOWS_MODIFIER_LABELS,\n Meta: 'Super',\n }\n\nexport const PUNCTUATION_KEY_DISPLAY_LABELS = {\n '`': 'Backquote',\n '\\\\': 'Backslash',\n '[': 'Left Bracket',\n ']': 'Right Bracket',\n ',': 'Comma',\n '=': 'Equal',\n '-': 'Minus',\n '.': 'Period',\n ';': 'Semicolon',\n} as const satisfies Record<string, string>\n\n/**\n * Special key symbols for display formatting.\n *\n * Maps certain keys to their visual symbols for better readability in hotkey displays.\n * Used by formatting functions to show symbols like ↑ for ArrowUp or ↵ for Enter\n * instead of text labels.\n *\n * @example\n * ```ts\n * KEY_DISPLAY_SYMBOLS['ArrowUp'] // '↑'\n * KEY_DISPLAY_SYMBOLS['Enter'] // '↵'\n * KEY_DISPLAY_SYMBOLS['Escape'] // 'Esc'\n * KEY_DISPLAY_SYMBOLS['Space'] // '␣'\n * ```\n */\nexport const KEY_DISPLAY_SYMBOLS = {\n ArrowUp: '↑',\n ArrowDown: '↓',\n ArrowLeft: '←',\n ArrowRight: '→',\n Enter: '↵',\n Escape: 'Esc',\n Backspace: '⌫',\n Delete: '⌦',\n Tab: '⇥',\n Space: '␣',\n} as const satisfies Record<string, string>\n"],"mappings":"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"}
@@ -183,6 +183,20 @@ declare const ALL_KEYS: Set<LetterKey | NumberKey | FunctionKey | NavigationKey
183
183
  * ```
184
184
  */
185
185
  declare function isSingleLetterKey(key: string): boolean;
186
+ /**
187
+ * Normalizes a key name to its canonical form.
188
+ *
189
+ * @param key - The key name to normalize (can be an alias, lowercase, etc.)
190
+ * @returns The canonical key name
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * normalizeKeyName('esc') // 'Escape'
195
+ * normalizeKeyName('a') // 'A'
196
+ * normalizeKeyName('f1') // 'F1'
197
+ * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)
198
+ * ```
199
+ */
186
200
  declare function normalizeKeyName(key: string): string;
187
201
  /**
188
202
  * Modifier key symbols for macOS display.
@@ -199,7 +213,23 @@ declare function normalizeKeyName(key: string): string;
199
213
  * MAC_MODIFIER_SYMBOLS['Shift'] // '⇧'
200
214
  * ```
201
215
  */
202
- declare const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier, string>;
216
+ declare const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier | 'Mod', string>;
217
+ /**
218
+ * Modifier key labels for macOS display.
219
+ *
220
+ * Used by formatting functions to display hotkeys with macOS-style text labels
221
+ * (e.g., 'Control' for Control, 'Option' for Alt, 'Cmd' for Meta) instead of symbols.
222
+ * This provides a familiar macOS look and feel in hotkey displays.
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * MAC_MODIFIER_LABELS['Control'] // 'control'
227
+ * MAC_MODIFIER_LABELS['Alt'] // 'option'
228
+ * MAC_MODIFIER_LABELS['Shift'] // 'shift'
229
+ * MAC_MODIFIER_LABELS['Meta'] // 'cmd'
230
+ * ```
231
+ */
232
+ declare const MAC_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
203
233
  /**
204
234
  * Modifier key labels for Windows/Linux display.
205
235
  *
@@ -215,7 +245,19 @@ declare const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier, string>;
215
245
  * STANDARD_MODIFIER_LABELS['Shift'] // 'Shift'
216
246
  * ```
217
247
  */
218
- declare const STANDARD_MODIFIER_LABELS: Record<CanonicalModifier, string>;
248
+ declare const WINDOWS_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
249
+ declare const LINUX_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
250
+ declare const PUNCTUATION_KEY_DISPLAY_LABELS: {
251
+ readonly '`': "Backquote";
252
+ readonly '\\': "Backslash";
253
+ readonly '[': "Left Bracket";
254
+ readonly ']': "Right Bracket";
255
+ readonly ',': "Comma";
256
+ readonly '=': "Equal";
257
+ readonly '-': "Minus";
258
+ readonly '.': "Period";
259
+ readonly ';': "Semicolon";
260
+ };
219
261
  /**
220
262
  * Special key symbols for display formatting.
221
263
  *
@@ -231,7 +273,18 @@ declare const STANDARD_MODIFIER_LABELS: Record<CanonicalModifier, string>;
231
273
  * KEY_DISPLAY_SYMBOLS['Space'] // '␣'
232
274
  * ```
233
275
  */
234
- declare const KEY_DISPLAY_SYMBOLS: Record<string, string>;
276
+ declare const KEY_DISPLAY_SYMBOLS: {
277
+ readonly ArrowUp: "↑";
278
+ readonly ArrowDown: "↓";
279
+ readonly ArrowLeft: "←";
280
+ readonly ArrowRight: "→";
281
+ readonly Enter: "↵";
282
+ readonly Escape: "Esc";
283
+ readonly Backspace: "⌫";
284
+ readonly Delete: "⌦";
285
+ readonly Tab: "⇥";
286
+ readonly Space: "␣";
287
+ };
235
288
  //#endregion
236
- export { ALL_KEYS, EDITING_KEYS, FUNCTION_KEYS, KEY_DISPLAY_SYMBOLS, LETTER_KEYS, MAC_MODIFIER_SYMBOLS, MODIFIER_ALIASES, MODIFIER_KEYS, MODIFIER_ORDER, NAVIGATION_KEYS, NUMBER_KEYS, PUNCTUATION_CODE_MAP, PUNCTUATION_KEYS, STANDARD_MODIFIER_LABELS, detectPlatform, isSingleLetterKey, normalizeKeyName, resolveModifier };
289
+ export { ALL_KEYS, EDITING_KEYS, FUNCTION_KEYS, KEY_DISPLAY_SYMBOLS, LETTER_KEYS, LINUX_MODIFIER_LABELS, MAC_MODIFIER_LABELS, MAC_MODIFIER_SYMBOLS, MODIFIER_ALIASES, MODIFIER_KEYS, MODIFIER_ORDER, NAVIGATION_KEYS, NUMBER_KEYS, PUNCTUATION_CODE_MAP, PUNCTUATION_KEYS, PUNCTUATION_KEY_DISPLAY_LABELS, WINDOWS_MODIFIER_LABELS, detectPlatform, isSingleLetterKey, normalizeKeyName, resolveModifier };
237
290
  //# sourceMappingURL=constants.d.cts.map
@@ -183,6 +183,20 @@ declare const ALL_KEYS: Set<LetterKey | NumberKey | FunctionKey | NavigationKey
183
183
  * ```
184
184
  */
185
185
  declare function isSingleLetterKey(key: string): boolean;
186
+ /**
187
+ * Normalizes a key name to its canonical form.
188
+ *
189
+ * @param key - The key name to normalize (can be an alias, lowercase, etc.)
190
+ * @returns The canonical key name
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * normalizeKeyName('esc') // 'Escape'
195
+ * normalizeKeyName('a') // 'A'
196
+ * normalizeKeyName('f1') // 'F1'
197
+ * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)
198
+ * ```
199
+ */
186
200
  declare function normalizeKeyName(key: string): string;
187
201
  /**
188
202
  * Modifier key symbols for macOS display.
@@ -199,7 +213,23 @@ declare function normalizeKeyName(key: string): string;
199
213
  * MAC_MODIFIER_SYMBOLS['Shift'] // '⇧'
200
214
  * ```
201
215
  */
202
- declare const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier, string>;
216
+ declare const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier | 'Mod', string>;
217
+ /**
218
+ * Modifier key labels for macOS display.
219
+ *
220
+ * Used by formatting functions to display hotkeys with macOS-style text labels
221
+ * (e.g., 'Control' for Control, 'Option' for Alt, 'Cmd' for Meta) instead of symbols.
222
+ * This provides a familiar macOS look and feel in hotkey displays.
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * MAC_MODIFIER_LABELS['Control'] // 'control'
227
+ * MAC_MODIFIER_LABELS['Alt'] // 'option'
228
+ * MAC_MODIFIER_LABELS['Shift'] // 'shift'
229
+ * MAC_MODIFIER_LABELS['Meta'] // 'cmd'
230
+ * ```
231
+ */
232
+ declare const MAC_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
203
233
  /**
204
234
  * Modifier key labels for Windows/Linux display.
205
235
  *
@@ -215,7 +245,19 @@ declare const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier, string>;
215
245
  * STANDARD_MODIFIER_LABELS['Shift'] // 'Shift'
216
246
  * ```
217
247
  */
218
- declare const STANDARD_MODIFIER_LABELS: Record<CanonicalModifier, string>;
248
+ declare const WINDOWS_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
249
+ declare const LINUX_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string>;
250
+ declare const PUNCTUATION_KEY_DISPLAY_LABELS: {
251
+ readonly '`': "Backquote";
252
+ readonly '\\': "Backslash";
253
+ readonly '[': "Left Bracket";
254
+ readonly ']': "Right Bracket";
255
+ readonly ',': "Comma";
256
+ readonly '=': "Equal";
257
+ readonly '-': "Minus";
258
+ readonly '.': "Period";
259
+ readonly ';': "Semicolon";
260
+ };
219
261
  /**
220
262
  * Special key symbols for display formatting.
221
263
  *
@@ -231,7 +273,18 @@ declare const STANDARD_MODIFIER_LABELS: Record<CanonicalModifier, string>;
231
273
  * KEY_DISPLAY_SYMBOLS['Space'] // '␣'
232
274
  * ```
233
275
  */
234
- declare const KEY_DISPLAY_SYMBOLS: Record<string, string>;
276
+ declare const KEY_DISPLAY_SYMBOLS: {
277
+ readonly ArrowUp: "↑";
278
+ readonly ArrowDown: "↓";
279
+ readonly ArrowLeft: "←";
280
+ readonly ArrowRight: "→";
281
+ readonly Enter: "↵";
282
+ readonly Escape: "Esc";
283
+ readonly Backspace: "⌫";
284
+ readonly Delete: "⌦";
285
+ readonly Tab: "⇥";
286
+ readonly Space: "␣";
287
+ };
235
288
  //#endregion
236
- export { ALL_KEYS, EDITING_KEYS, FUNCTION_KEYS, KEY_DISPLAY_SYMBOLS, LETTER_KEYS, MAC_MODIFIER_SYMBOLS, MODIFIER_ALIASES, MODIFIER_KEYS, MODIFIER_ORDER, NAVIGATION_KEYS, NUMBER_KEYS, PUNCTUATION_CODE_MAP, PUNCTUATION_KEYS, STANDARD_MODIFIER_LABELS, detectPlatform, isSingleLetterKey, normalizeKeyName, resolveModifier };
289
+ export { ALL_KEYS, EDITING_KEYS, FUNCTION_KEYS, KEY_DISPLAY_SYMBOLS, LETTER_KEYS, LINUX_MODIFIER_LABELS, MAC_MODIFIER_LABELS, MAC_MODIFIER_SYMBOLS, MODIFIER_ALIASES, MODIFIER_KEYS, MODIFIER_ORDER, NAVIGATION_KEYS, NUMBER_KEYS, PUNCTUATION_CODE_MAP, PUNCTUATION_KEYS, PUNCTUATION_KEY_DISPLAY_LABELS, WINDOWS_MODIFIER_LABELS, detectPlatform, isSingleLetterKey, normalizeKeyName, resolveModifier };
237
290
  //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -86,6 +86,10 @@ const MODIFIER_ALIASES = {
86
86
  command: "Meta",
87
87
  cmd: "Meta",
88
88
  meta: "Meta",
89
+ OS: "Meta",
90
+ os: "Meta",
91
+ Win: "Meta",
92
+ win: "Meta",
89
93
  CommandOrControl: "Mod",
90
94
  Mod: "Mod",
91
95
  commandorcontrol: "Mod",
@@ -255,16 +259,16 @@ const PUNCTUATION_KEYS = new Set([
255
259
  * fallbacks for letters and digits.
256
260
  */
257
261
  const PUNCTUATION_CODE_MAP = {
258
- Minus: "-",
259
- Equal: "=",
260
- Slash: "/",
262
+ Backquote: "`",
263
+ Backslash: "\\",
261
264
  BracketLeft: "[",
262
265
  BracketRight: "]",
263
- Backslash: "\\",
264
266
  Comma: ",",
267
+ Equal: "=",
268
+ Minus: "-",
265
269
  Period: ".",
266
- Backquote: "`",
267
- Semicolon: ";"
270
+ Semicolon: ";",
271
+ Slash: "/"
268
272
  };
269
273
  /**
270
274
  * Set of all valid non-modifier keys.
@@ -371,6 +375,20 @@ const KEY_ALIASES = {
371
375
  function isSingleLetterKey(key) {
372
376
  return /^\p{Letter}$/u.test(key);
373
377
  }
378
+ /**
379
+ * Normalizes a key name to its canonical form.
380
+ *
381
+ * @param key - The key name to normalize (can be an alias, lowercase, etc.)
382
+ * @returns The canonical key name
383
+ *
384
+ * @example
385
+ * ```ts
386
+ * normalizeKeyName('esc') // 'Escape'
387
+ * normalizeKeyName('a') // 'A'
388
+ * normalizeKeyName('f1') // 'F1'
389
+ * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)
390
+ * ```
391
+ */
374
392
  function normalizeKeyName(key) {
375
393
  if (key in KEY_ALIASES) return KEY_ALIASES[key];
376
394
  if (isSingleLetterKey(key)) {
@@ -400,7 +418,30 @@ const MAC_MODIFIER_SYMBOLS = {
400
418
  Control: "⌃",
401
419
  Alt: "⌥",
402
420
  Shift: "⇧",
403
- Meta: "⌘"
421
+ Meta: "⌘",
422
+ Mod: "⌘"
423
+ };
424
+ /**
425
+ * Modifier key labels for macOS display.
426
+ *
427
+ * Used by formatting functions to display hotkeys with macOS-style text labels
428
+ * (e.g., 'Control' for Control, 'Option' for Alt, 'Cmd' for Meta) instead of symbols.
429
+ * This provides a familiar macOS look and feel in hotkey displays.
430
+ *
431
+ * @example
432
+ * ```ts
433
+ * MAC_MODIFIER_LABELS['Control'] // 'control'
434
+ * MAC_MODIFIER_LABELS['Alt'] // 'option'
435
+ * MAC_MODIFIER_LABELS['Shift'] // 'shift'
436
+ * MAC_MODIFIER_LABELS['Meta'] // 'cmd'
437
+ * ```
438
+ */
439
+ const MAC_MODIFIER_LABELS = {
440
+ Control: "Control",
441
+ Alt: "Option",
442
+ Shift: "Shift",
443
+ Meta: "Cmd",
444
+ Mod: "Cmd"
404
445
  };
405
446
  /**
406
447
  * Modifier key labels for Windows/Linux display.
@@ -417,11 +458,27 @@ const MAC_MODIFIER_SYMBOLS = {
417
458
  * STANDARD_MODIFIER_LABELS['Shift'] // 'Shift'
418
459
  * ```
419
460
  */
420
- const STANDARD_MODIFIER_LABELS = {
461
+ const WINDOWS_MODIFIER_LABELS = {
421
462
  Control: "Ctrl",
422
463
  Alt: "Alt",
423
464
  Shift: "Shift",
424
- Meta: "Win"
465
+ Meta: "Win",
466
+ Mod: "Ctrl"
467
+ };
468
+ const LINUX_MODIFIER_LABELS = {
469
+ ...WINDOWS_MODIFIER_LABELS,
470
+ Meta: "Super"
471
+ };
472
+ const PUNCTUATION_KEY_DISPLAY_LABELS = {
473
+ "`": "Backquote",
474
+ "\\": "Backslash",
475
+ "[": "Left Bracket",
476
+ "]": "Right Bracket",
477
+ ",": "Comma",
478
+ "=": "Equal",
479
+ "-": "Minus",
480
+ ".": "Period",
481
+ ";": "Semicolon"
425
482
  };
426
483
  /**
427
484
  * Special key symbols for display formatting.
@@ -452,5 +509,5 @@ const KEY_DISPLAY_SYMBOLS = {
452
509
  };
453
510
 
454
511
  //#endregion
455
- export { ALL_KEYS, EDITING_KEYS, FUNCTION_KEYS, KEY_DISPLAY_SYMBOLS, LETTER_KEYS, MAC_MODIFIER_SYMBOLS, MODIFIER_ALIASES, MODIFIER_KEYS, MODIFIER_ORDER, NAVIGATION_KEYS, NUMBER_KEYS, PUNCTUATION_CODE_MAP, PUNCTUATION_KEYS, STANDARD_MODIFIER_LABELS, detectPlatform, isSingleLetterKey, normalizeKeyName, resolveModifier };
512
+ export { ALL_KEYS, EDITING_KEYS, FUNCTION_KEYS, KEY_DISPLAY_SYMBOLS, LETTER_KEYS, LINUX_MODIFIER_LABELS, MAC_MODIFIER_LABELS, MAC_MODIFIER_SYMBOLS, MODIFIER_ALIASES, MODIFIER_KEYS, MODIFIER_ORDER, NAVIGATION_KEYS, NUMBER_KEYS, PUNCTUATION_CODE_MAP, PUNCTUATION_KEYS, PUNCTUATION_KEY_DISPLAY_LABELS, WINDOWS_MODIFIER_LABELS, detectPlatform, isSingleLetterKey, normalizeKeyName, resolveModifier };
456
513
  //# sourceMappingURL=constants.js.map