@tanstack/hotkeys 0.9.0 → 0.10.1

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 (148) hide show
  1. package/dist/_event-target.js +1 -2
  2. package/dist/_keyboard-event.js +1 -2
  3. package/dist/_match.js +1 -2
  4. package/dist/_named-keys.d.ts +3 -5
  5. package/dist/_named-keys.js +1 -2
  6. package/dist/_recorder-chord.js +1 -2
  7. package/dist/_recording-guard.js +1 -2
  8. package/dist/_registration.js +1 -2
  9. package/dist/conflicts.d.ts +4 -7
  10. package/dist/conflicts.js +1 -2
  11. package/dist/constants.d.ts +14 -17
  12. package/dist/constants.js +8 -9
  13. package/dist/display-labels.d.ts +7 -10
  14. package/dist/display-labels.js +1 -2
  15. package/dist/format.d.ts +12 -14
  16. package/dist/format.js +17 -7
  17. package/dist/hint.d.ts +3 -6
  18. package/dist/hint.js +1 -2
  19. package/dist/hotkey-manager.d.ts +8 -10
  20. package/dist/hotkey-manager.js +21 -3
  21. package/dist/hotkey-recorder.d.ts +4 -7
  22. package/dist/hotkey-recorder.js +9 -6
  23. package/dist/hotkey-sequence-recorder.d.ts +5 -8
  24. package/dist/hotkey-sequence-recorder.js +6 -7
  25. package/dist/hotkey.types.d.ts +15 -18
  26. package/dist/key-state-tracker.d.ts +4 -7
  27. package/dist/key-state-tracker.js +6 -3
  28. package/dist/key.types.d.ts +17 -20
  29. package/dist/match.d.ts +8 -11
  30. package/dist/match.js +1 -2
  31. package/dist/parse.d.ts +11 -14
  32. package/dist/parse.js +5 -4
  33. package/dist/platform.d.ts +3 -6
  34. package/dist/platform.js +1 -2
  35. package/dist/recorder-options.d.ts +6 -9
  36. package/dist/sequence-manager.d.ts +11 -14
  37. package/dist/sequence-manager.js +12 -7
  38. package/dist/validate.d.ts +5 -8
  39. package/dist/validate.js +1 -2
  40. package/package.json +8 -13
  41. package/dist/_event-target.cjs +0 -73
  42. package/dist/_event-target.cjs.map +0 -1
  43. package/dist/_event-target.js.map +0 -1
  44. package/dist/_keyboard-event.cjs +0 -83
  45. package/dist/_keyboard-event.cjs.map +0 -1
  46. package/dist/_keyboard-event.js.map +0 -1
  47. package/dist/_match.cjs +0 -49
  48. package/dist/_match.cjs.map +0 -1
  49. package/dist/_match.js.map +0 -1
  50. package/dist/_named-keys.cjs +0 -68
  51. package/dist/_named-keys.cjs.map +0 -1
  52. package/dist/_named-keys.d.cts +0 -8
  53. package/dist/_named-keys.js.map +0 -1
  54. package/dist/_recorder-chord.cjs +0 -44
  55. package/dist/_recorder-chord.cjs.map +0 -1
  56. package/dist/_recorder-chord.js.map +0 -1
  57. package/dist/_recording-guard.cjs +0 -59
  58. package/dist/_recording-guard.cjs.map +0 -1
  59. package/dist/_recording-guard.js.map +0 -1
  60. package/dist/_registration.cjs +0 -54
  61. package/dist/_registration.cjs.map +0 -1
  62. package/dist/_registration.js.map +0 -1
  63. package/dist/conflicts.cjs +0 -55
  64. package/dist/conflicts.cjs.map +0 -1
  65. package/dist/conflicts.d.cts +0 -39
  66. package/dist/conflicts.js.map +0 -1
  67. package/dist/constants.cjs +0 -410
  68. package/dist/constants.cjs.map +0 -1
  69. package/dist/constants.d.cts +0 -165
  70. package/dist/constants.js.map +0 -1
  71. package/dist/display-labels.cjs +0 -119
  72. package/dist/display-labels.cjs.map +0 -1
  73. package/dist/display-labels.d.cts +0 -93
  74. package/dist/display-labels.js.map +0 -1
  75. package/dist/format.cjs +0 -85
  76. package/dist/format.cjs.map +0 -1
  77. package/dist/format.d.cts +0 -99
  78. package/dist/format.js.map +0 -1
  79. package/dist/hint.cjs +0 -24
  80. package/dist/hint.cjs.map +0 -1
  81. package/dist/hint.d.cts +0 -23
  82. package/dist/hint.js.map +0 -1
  83. package/dist/hotkey-manager.cjs +0 -414
  84. package/dist/hotkey-manager.cjs.map +0 -1
  85. package/dist/hotkey-manager.d.cts +0 -234
  86. package/dist/hotkey-manager.js.map +0 -1
  87. package/dist/hotkey-recorder.cjs +0 -235
  88. package/dist/hotkey-recorder.cjs.map +0 -1
  89. package/dist/hotkey-recorder.d.cts +0 -119
  90. package/dist/hotkey-recorder.js.map +0 -1
  91. package/dist/hotkey-sequence-recorder.cjs +0 -255
  92. package/dist/hotkey-sequence-recorder.cjs.map +0 -1
  93. package/dist/hotkey-sequence-recorder.d.cts +0 -86
  94. package/dist/hotkey-sequence-recorder.js.map +0 -1
  95. package/dist/hotkey.types.d.cts +0 -236
  96. package/dist/index.cjs +0 -71
  97. package/dist/index.d.cts +0 -18
  98. package/dist/key-state-tracker.cjs +0 -197
  99. package/dist/key-state-tracker.cjs.map +0 -1
  100. package/dist/key-state-tracker.d.cts +0 -107
  101. package/dist/key-state-tracker.js.map +0 -1
  102. package/dist/key.types.d.cts +0 -82
  103. package/dist/match.cjs +0 -144
  104. package/dist/match.cjs.map +0 -1
  105. package/dist/match.d.cts +0 -101
  106. package/dist/match.js.map +0 -1
  107. package/dist/parse.cjs +0 -245
  108. package/dist/parse.cjs.map +0 -1
  109. package/dist/parse.d.cts +0 -134
  110. package/dist/parse.js.map +0 -1
  111. package/dist/platform.cjs +0 -55
  112. package/dist/platform.cjs.map +0 -1
  113. package/dist/platform.d.cts +0 -44
  114. package/dist/platform.js.map +0 -1
  115. package/dist/recorder-options.d.cts +0 -34
  116. package/dist/sequence-manager.cjs +0 -441
  117. package/dist/sequence-manager.cjs.map +0 -1
  118. package/dist/sequence-manager.d.cts +0 -172
  119. package/dist/sequence-manager.js.map +0 -1
  120. package/dist/validate.cjs +0 -112
  121. package/dist/validate.cjs.map +0 -1
  122. package/dist/validate.d.cts +0 -67
  123. package/dist/validate.js.map +0 -1
  124. package/src/_event-target.ts +0 -157
  125. package/src/_keyboard-event.ts +0 -101
  126. package/src/_match.ts +0 -96
  127. package/src/_named-keys.ts +0 -62
  128. package/src/_recorder-chord.ts +0 -76
  129. package/src/_recording-guard.ts +0 -63
  130. package/src/_registration.ts +0 -79
  131. package/src/conflicts.ts +0 -125
  132. package/src/constants.ts +0 -455
  133. package/src/display-labels.ts +0 -123
  134. package/src/format.ts +0 -201
  135. package/src/hint.ts +0 -42
  136. package/src/hotkey-manager.ts +0 -814
  137. package/src/hotkey-recorder.ts +0 -348
  138. package/src/hotkey-sequence-recorder.ts +0 -410
  139. package/src/hotkey.types.ts +0 -269
  140. package/src/index.ts +0 -17
  141. package/src/key-state-tracker.ts +0 -261
  142. package/src/key.types.ts +0 -268
  143. package/src/match.ts +0 -210
  144. package/src/parse.ts +0 -369
  145. package/src/platform.ts +0 -66
  146. package/src/recorder-options.ts +0 -34
  147. package/src/sequence-manager.ts +0 -769
  148. package/src/validate.ts +0 -179
package/src/constants.ts DELETED
@@ -1,455 +0,0 @@
1
- import { LOGICAL_ONLY_NAMED_KEYS, SHARED_NAMED_KEYS } from './_named-keys'
2
- import type {
3
- CanonicalModifier,
4
- EditingKey,
5
- FunctionKey,
6
- LetterKey,
7
- NavigationKey,
8
- NumberKey,
9
- PunctuationKey,
10
- } from './key.types'
11
-
12
- /**
13
- * Canonical order for modifiers in normalized hotkey strings.
14
- *
15
- * Defines the standard order in which modifiers should appear when formatting
16
- * hotkeys. This ensures consistent, predictable output across the library.
17
- *
18
- * Order: Control → Alt → Shift → Meta
19
- *
20
- * @example
21
- * ```ts
22
- * // Input: 'Shift+Control+Meta+S'
23
- * // Normalized: 'Control+Alt+Shift+Meta+S' (following MODIFIER_ORDER)
24
- * ```
25
- */
26
- export const MODIFIER_ORDER: Array<CanonicalModifier> = [
27
- 'Control',
28
- 'Alt',
29
- 'Shift',
30
- 'Meta',
31
- ]
32
-
33
- /**
34
- * Set of canonical modifier key names for fast lookup.
35
- *
36
- * Derived from `MODIFIER_ORDER` to ensure consistency. Used to detect when
37
- * a modifier is released so we can clear non-modifier keys whose keyup events
38
- * may have been swallowed by the OS (e.g. macOS Cmd+key combos).
39
- */
40
- export const MODIFIER_KEYS = new Set<string>(MODIFIER_ORDER)
41
-
42
- /**
43
- * Maps modifier key aliases to their canonical form or platform-adaptive 'Mod'.
44
- *
45
- * This map allows users to write hotkeys using various aliases (e.g., 'Ctrl', 'Cmd', 'Option')
46
- * which are then normalized to canonical names ('Control', 'Meta', 'Alt') or the
47
- * platform-adaptive 'Mod' token.
48
- *
49
- * The 'Mod' and 'CommandOrControl' aliases are resolved at runtime via `resolveModifier()`
50
- * based on the detected platform (Command on Mac, Control elsewhere).
51
- *
52
- * @remarks Case-insensitive lookups are supported via lowercase variants
53
- *
54
- * @example
55
- * ```ts
56
- * MODIFIER_ALIASES['Ctrl'] // 'Control'
57
- * MODIFIER_ALIASES['Cmd'] // 'Meta'
58
- * MODIFIER_ALIASES['Mod'] // 'Mod' (resolved at runtime)
59
- * ```
60
- */
61
- export const MODIFIER_ALIASES: Record<string, CanonicalModifier | 'Mod'> = {
62
- // Control variants
63
- Control: 'Control',
64
- Ctrl: 'Control',
65
- control: 'Control',
66
- ctrl: 'Control',
67
-
68
- // Shift variants
69
- Shift: 'Shift',
70
- shift: 'Shift',
71
-
72
- // Alt variants
73
- Alt: 'Alt',
74
- Option: 'Alt',
75
- alt: 'Alt',
76
- option: 'Alt',
77
-
78
- // Meta/Command variants
79
- Command: 'Meta',
80
- Cmd: 'Meta',
81
- Meta: 'Meta',
82
- command: 'Meta',
83
- cmd: 'Meta',
84
- meta: 'Meta',
85
-
86
- // DOM `KeyboardEvent.key` spellings for the meta / Windows key
87
- OS: 'Meta',
88
- os: 'Meta',
89
- Win: 'Meta',
90
- win: 'Meta',
91
-
92
- // Platform-adaptive (resolved at runtime)
93
- CommandOrControl: 'Mod',
94
- Mod: 'Mod',
95
- commandorcontrol: 'Mod',
96
- mod: 'Mod',
97
- }
98
-
99
- /**
100
- * Set of all valid letter keys (A-Z).
101
- *
102
- * Used for validation and type checking. Letter keys are matched case-insensitively
103
- * in hotkey matching, but normalized to uppercase in canonical form.
104
- */
105
- export const LETTER_KEYS = new Set<LetterKey>([
106
- 'A',
107
- 'B',
108
- 'C',
109
- 'D',
110
- 'E',
111
- 'F',
112
- 'G',
113
- 'H',
114
- 'I',
115
- 'J',
116
- 'K',
117
- 'L',
118
- 'M',
119
- 'N',
120
- 'O',
121
- 'P',
122
- 'Q',
123
- 'R',
124
- 'S',
125
- 'T',
126
- 'U',
127
- 'V',
128
- 'W',
129
- 'X',
130
- 'Y',
131
- 'Z',
132
- ])
133
-
134
- /**
135
- * Set of all valid number keys (0-9).
136
- *
137
- * Note: Number keys are affected by Shift (Shift+1 → '!' on US layout),
138
- * so they're excluded from Shift-based hotkey combinations to avoid
139
- * layout-dependent behavior.
140
- */
141
- export const NUMBER_KEYS = new Set<NumberKey>([
142
- '0',
143
- '1',
144
- '2',
145
- '3',
146
- '4',
147
- '5',
148
- '6',
149
- '7',
150
- '8',
151
- '9',
152
- ])
153
-
154
- /**
155
- * Set of all valid function keys (F1-F24).
156
- *
157
- * Function keys are commonly used for system shortcuts (e.g., F12 for DevTools,
158
- * Alt+F4 to close windows) and application-specific commands.
159
- */
160
- export const FUNCTION_KEYS = new Set<FunctionKey>([
161
- 'F1',
162
- 'F2',
163
- 'F3',
164
- 'F4',
165
- 'F5',
166
- 'F6',
167
- 'F7',
168
- 'F8',
169
- 'F9',
170
- 'F10',
171
- 'F11',
172
- 'F12',
173
- 'F13',
174
- 'F14',
175
- 'F15',
176
- 'F16',
177
- 'F17',
178
- 'F18',
179
- 'F19',
180
- 'F20',
181
- 'F21',
182
- 'F22',
183
- 'F23',
184
- 'F24',
185
- ])
186
-
187
- /**
188
- * Set of all valid navigation keys for cursor movement and document navigation.
189
- *
190
- * Includes arrow keys, Home/End (line navigation), and PageUp/PageDown (page navigation).
191
- * These keys are commonly combined with modifiers for selection (Shift+ArrowUp) or
192
- * navigation shortcuts (Alt+ArrowLeft for back).
193
- */
194
- export const NAVIGATION_KEYS = new Set<NavigationKey>([
195
- 'ArrowUp',
196
- 'ArrowDown',
197
- 'ArrowLeft',
198
- 'ArrowRight',
199
- 'Home',
200
- 'End',
201
- 'PageUp',
202
- 'PageDown',
203
- ])
204
-
205
- /**
206
- * Set of all valid editing and special keys.
207
- *
208
- * Includes keys commonly used for text editing (Enter, Backspace, Delete, Tab) and
209
- * special actions (Escape, Space). These keys are frequently combined with modifiers
210
- * for editor shortcuts (Mod+Enter to submit, Shift+Tab to go back).
211
- */
212
- export const EDITING_KEYS = new Set<EditingKey>([
213
- 'Enter',
214
- 'Escape',
215
- 'Space',
216
- 'Tab',
217
- 'Backspace',
218
- 'Delete',
219
- ])
220
-
221
- /**
222
- * Set of all valid punctuation keys commonly used in keyboard shortcuts.
223
- *
224
- * These are the literal characters as they appear in `KeyboardEvent.key` (layout-dependent,
225
- * typically US keyboard layout). Common shortcuts include:
226
- * - `Mod+/` - Toggle comment
227
- * - `Mod+[` / `Mod+]` - Indent/outdent
228
- * - `Mod+=` / `Mod+-` - Zoom in/out
229
- *
230
- * Note: Punctuation keys are affected by Shift (Shift+',' → '<' on US layout),
231
- * so they're excluded from Shift-based hotkey combinations to avoid layout-dependent behavior.
232
- */
233
- export const PUNCTUATION_KEYS = new Set<PunctuationKey>([
234
- '/',
235
- '[',
236
- ']',
237
- '\\',
238
- '=',
239
- '-',
240
- ',',
241
- '.',
242
- ';',
243
- '`',
244
- "'",
245
- '+',
246
- '?',
247
- '!',
248
- '@',
249
- '#',
250
- '$',
251
- '%',
252
- '^',
253
- '&',
254
- '*',
255
- '(',
256
- ')',
257
- '_',
258
- '{',
259
- '}',
260
- '|',
261
- ':',
262
- '"',
263
- '<',
264
- '>',
265
- '~',
266
- ])
267
-
268
- /**
269
- * Maps `KeyboardEvent.code` values for punctuation keys to their canonical characters.
270
- *
271
- * On macOS, holding the Option (Alt) key transforms punctuation keys into special characters
272
- * (e.g., Option+Minus → en-dash '–'), causing `event.key` to differ from the expected character.
273
- * However, `event.code` still reports the physical key (e.g., 'Minus'). This map enables
274
- * falling back to `event.code` for punctuation keys, similar to the existing `Key*`/`Digit*`
275
- * fallbacks for letters and digits.
276
- */
277
- export const PUNCTUATION_CODE_MAP: Record<string, string> = {
278
- Backquote: '`',
279
- Backslash: '\\',
280
- BracketLeft: '[',
281
- BracketRight: ']',
282
- Comma: ',',
283
- Equal: '=',
284
- Minus: '-',
285
- Period: '.',
286
- Quote: "'",
287
- Semicolon: ';',
288
- Slash: '/',
289
- }
290
-
291
- /**
292
- * Set of all valid non-modifier keys.
293
- *
294
- * This is the union of all key type sets (letters, numbers, function keys, navigation,
295
- * editing, and punctuation). Used primarily for validation to check if a key string
296
- * is recognized and will have type-safe autocomplete support.
297
- *
298
- * @see {@link LETTER_KEYS}
299
- * @see {@link NUMBER_KEYS}
300
- * @see {@link FUNCTION_KEYS}
301
- * @see {@link NAVIGATION_KEYS}
302
- * @see {@link EDITING_KEYS}
303
- * @see {@link PUNCTUATION_KEYS}
304
- */
305
- export const ALL_KEYS = new Set([
306
- ...LETTER_KEYS,
307
- ...NUMBER_KEYS,
308
- ...FUNCTION_KEYS,
309
- ...NAVIGATION_KEYS,
310
- ...EDITING_KEYS,
311
- ...PUNCTUATION_KEYS,
312
- ...SHARED_NAMED_KEYS,
313
- ...LOGICAL_ONLY_NAMED_KEYS,
314
- ])
315
-
316
- // Share canonical spellings with validation, including newly supported named keys.
317
- const CANONICAL_KEY_NAMES = new Map<string, string>(
318
- Array.from(ALL_KEYS, (key) => [key.toLowerCase(), key]),
319
- )
320
-
321
- /**
322
- * Maps key name aliases to their canonical form.
323
- *
324
- * Handles common variations and alternative names for keys to provide a more
325
- * forgiving API. For example, users can write 'Esc', 'esc', or 'escape' and
326
- * they'll all normalize to 'Escape'.
327
- *
328
- * This map is used internally by `normalizeKeyName()` to convert user input
329
- * into the canonical key names used throughout the library.
330
- *
331
- * @remarks Case-insensitive lookups are supported via lowercase variants
332
- *
333
- * @example
334
- * ```ts
335
- * KEY_ALIASES['Esc'] // 'Escape'
336
- * KEY_ALIASES['Del'] // 'Delete'
337
- * KEY_ALIASES['Up'] // 'ArrowUp'
338
- * ```
339
- */
340
- const KEY_ALIASES: Record<string, string> = {
341
- Plus: '+',
342
- plus: '+',
343
- // Escape variants
344
- Esc: 'Escape',
345
- esc: 'Escape',
346
- escape: 'Escape',
347
-
348
- // Enter variants
349
- Return: 'Enter',
350
- return: 'Enter',
351
- enter: 'Enter',
352
-
353
- // Space variants
354
- ' ': 'Space',
355
- space: 'Space',
356
- Spacebar: 'Space',
357
- spacebar: 'Space',
358
-
359
- // Tab variants
360
- tab: 'Tab',
361
-
362
- // Backspace variants
363
- backspace: 'Backspace',
364
-
365
- // Delete variants
366
- Del: 'Delete',
367
- del: 'Delete',
368
- delete: 'Delete',
369
-
370
- // Arrow key variants
371
- Up: 'ArrowUp',
372
- up: 'ArrowUp',
373
- arrowup: 'ArrowUp',
374
- Down: 'ArrowDown',
375
- down: 'ArrowDown',
376
- arrowdown: 'ArrowDown',
377
- Left: 'ArrowLeft',
378
- left: 'ArrowLeft',
379
- arrowleft: 'ArrowLeft',
380
- Right: 'ArrowRight',
381
- right: 'ArrowRight',
382
- arrowright: 'ArrowRight',
383
-
384
- // Navigation variants
385
- home: 'Home',
386
- end: 'End',
387
- pageup: 'PageUp',
388
- pagedown: 'PageDown',
389
- PgUp: 'PageUp',
390
- PgDn: 'PageDown',
391
- pgup: 'PageUp',
392
- pgdn: 'PageDown',
393
- }
394
-
395
- /**
396
- * Normalizes a key name to its canonical form.
397
- *
398
- * Converts various key name formats (aliases, case variations) into the standard
399
- * canonical names used throughout the library. This enables a more forgiving API
400
- * where users can write keys in different ways and still get correct behavior.
401
- *
402
- * Normalization rules:
403
- * 1. Check aliases first (e.g., 'Esc' → 'Escape', 'Del' → 'Delete')
404
- * 2. Single letters → uppercase (e.g., 'a' → 'A', 's' → 'S')
405
- * 3. Function keys → uppercase (e.g., 'f1' → 'F1', 'F12' → 'F12')
406
- * 4. Other keys → returned as-is (already canonical or unknown)
407
- *
408
- * @param key - The key name to normalize (can be an alias, lowercase, etc.)
409
- * @returns The canonical key name
410
- *
411
- * @example
412
- * ```ts
413
- * normalizeKeyName('esc') // 'Escape'
414
- * normalizeKeyName('a') // 'A'
415
- * normalizeKeyName('f1') // 'F1'
416
- * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)
417
- * ```
418
- */
419
- export function isSingleLetterKey(key: string): boolean {
420
- return /^\p{Letter}$/u.test(key)
421
- }
422
-
423
- /**
424
- * Normalizes a key name to its canonical form.
425
- *
426
- * @param key - The key name to normalize (can be an alias, lowercase, etc.)
427
- * @returns The canonical key name
428
- *
429
- * @example
430
- * ```ts
431
- * normalizeKeyName('esc') // 'Escape'
432
- * normalizeKeyName('a') // 'A'
433
- * normalizeKeyName('f1') // 'F1'
434
- * normalizeKeyName('ArrowUp') // 'ArrowUp' (already canonical)
435
- * ```
436
- */
437
- export function normalizeKeyName(key: string): string {
438
- // key can be undefined in rare cases
439
- // (browser extensions synthesizing key events, accessibility tools, certain OS/browser combinations).
440
- if (!key) return ''
441
- // Check aliases first
442
- if (key in KEY_ALIASES) {
443
- return KEY_ALIASES[key]!
444
- }
445
-
446
- if (isSingleLetterKey(key)) {
447
- const upper = key.toUpperCase()
448
- // Some Unicode letters (e.g., 'ß') uppercase to multi-character sequences
449
- // ('SS'). Avoid changing the string length so the rest of the matching
450
- // logic can rely on a stable single-character key value.
451
- return upper.length === 1 ? upper : key
452
- }
453
-
454
- return CANONICAL_KEY_NAMES.get(key.toLowerCase()) ?? key
455
- }
@@ -1,123 +0,0 @@
1
- import type { CanonicalModifier } from './key.types'
2
-
3
- // =============================================================================
4
- // Display Symbols
5
- // =============================================================================
6
-
7
- /**
8
- * Modifier key symbols for macOS display.
9
- *
10
- * Used by formatting functions to display hotkeys with macOS-style symbols
11
- * (e.g., ⌘ for Command, ⌃ for Control) instead of text labels. This provides
12
- * a native macOS look and feel in hotkey displays.
13
- *
14
- * @example
15
- * ```ts
16
- * MAC_MODIFIER_SYMBOLS['Meta'] // '⌘'
17
- * MAC_MODIFIER_SYMBOLS['Control'] // '⌃'
18
- * MAC_MODIFIER_SYMBOLS['Alt'] // '⌥'
19
- * MAC_MODIFIER_SYMBOLS['Shift'] // '⇧'
20
- * ```
21
- */
22
- export const MAC_MODIFIER_SYMBOLS: Record<CanonicalModifier | 'Mod', string> = {
23
- Control: '⌃',
24
- Alt: '⌥',
25
- Shift: '⇧',
26
- Meta: '⌘',
27
- Mod: '⌘',
28
- }
29
-
30
- /**
31
- * Modifier key labels for macOS display.
32
- *
33
- * Used by formatting functions to display hotkeys with macOS-style text labels
34
- * (e.g., 'Control' for Control, 'Option' for Alt, 'Cmd' for Meta) instead of symbols.
35
- * This provides a familiar macOS look and feel in hotkey displays.
36
- *
37
- * @example
38
- * ```ts
39
- * MAC_MODIFIER_LABELS['Control'] // 'control'
40
- * MAC_MODIFIER_LABELS['Alt'] // 'option'
41
- * MAC_MODIFIER_LABELS['Shift'] // 'shift'
42
- * MAC_MODIFIER_LABELS['Meta'] // 'cmd'
43
- * ```
44
- */
45
- export const MAC_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string> = {
46
- Control: 'Control',
47
- Alt: 'Option',
48
- Shift: 'Shift',
49
- Meta: 'Cmd',
50
- Mod: 'Cmd',
51
- }
52
-
53
- /**
54
- * Modifier key labels for Windows/Linux display.
55
- *
56
- * Used by formatting functions to display hotkeys with standard text labels
57
- * (e.g., 'Ctrl' for Control, 'Win' for Meta/Windows key) instead of symbols.
58
- * This provides a familiar Windows/Linux look and feel in hotkey displays.
59
- *
60
- * @example
61
- * ```ts
62
- * STANDARD_MODIFIER_LABELS['Control'] // 'Ctrl'
63
- * STANDARD_MODIFIER_LABELS['Meta'] // 'Win'
64
- * STANDARD_MODIFIER_LABELS['Alt'] // 'Alt'
65
- * STANDARD_MODIFIER_LABELS['Shift'] // 'Shift'
66
- * ```
67
- */
68
- export const WINDOWS_MODIFIER_LABELS: Record<
69
- CanonicalModifier | 'Mod',
70
- string
71
- > = {
72
- Control: 'Ctrl',
73
- Alt: 'Alt',
74
- Shift: 'Shift',
75
- Meta: 'Win',
76
- Mod: 'Ctrl',
77
- }
78
-
79
- export const LINUX_MODIFIER_LABELS: Record<CanonicalModifier | 'Mod', string> =
80
- {
81
- ...WINDOWS_MODIFIER_LABELS,
82
- Meta: 'Super',
83
- }
84
-
85
- export const PUNCTUATION_KEY_DISPLAY_LABELS = {
86
- '`': 'Backquote',
87
- '\\': 'Backslash',
88
- '[': 'Left Bracket',
89
- ']': 'Right Bracket',
90
- ',': 'Comma',
91
- '=': 'Equal',
92
- '-': 'Minus',
93
- '.': 'Period',
94
- ';': 'Semicolon',
95
- } as const satisfies Record<string, string>
96
-
97
- /**
98
- * Special key symbols for display formatting.
99
- *
100
- * Maps certain keys to their visual symbols for better readability in hotkey displays.
101
- * Used by formatting functions to show symbols like ↑ for ArrowUp or ↵ for Enter
102
- * instead of text labels.
103
- *
104
- * @example
105
- * ```ts
106
- * KEY_DISPLAY_SYMBOLS['ArrowUp'] // '↑'
107
- * KEY_DISPLAY_SYMBOLS['Enter'] // '↵'
108
- * KEY_DISPLAY_SYMBOLS['Escape'] // 'Esc'
109
- * KEY_DISPLAY_SYMBOLS['Space'] // '␣'
110
- * ```
111
- */
112
- export const KEY_DISPLAY_SYMBOLS = {
113
- ArrowUp: '↑',
114
- ArrowDown: '↓',
115
- ArrowLeft: '←',
116
- ArrowRight: '→',
117
- Enter: '↵',
118
- Escape: 'Esc',
119
- Backspace: '⌫',
120
- Delete: '⌦',
121
- Tab: '⇥',
122
- Space: '␣',
123
- } as const satisfies Record<string, string>