formatShortcut.ts8 lines · main
| 1 | /** |
| 2 | * Convert a TanStack Hotkeys hotkey string (e.g. `"Mod+Shift+M"`) into the |
| 3 | * key-array format consumed by the `<KeyboardShortcut />` component from `ui` |
| 4 | * (e.g. `["Meta", "Shift", "M"]`). `KeyboardShortcut` resolves `Meta` to ⌘ on |
| 5 | * macOS or `Ctrl` elsewhere, so this mapping is platform-safe. |
| 6 | */ |
| 7 | export const hotkeyToKeys = (hotkey: string): string[] => |
| 8 | hotkey.split('+').map((part) => (part === 'Mod' ? 'Meta' : part)) |