-
Notifications
You must be signed in to change notification settings - Fork 0
Keyboard Shortcuts
ABCrimson edited this page Mar 11, 2026
·
2 revisions
Shortcuts use a modifier+key string format:
| Syntax | Meaning |
|---|---|
Mod+K |
Cmd+K on macOS, Ctrl+K on Windows/Linux |
Ctrl+Shift+P |
Ctrl+Shift+P on all platforms |
Alt+N |
Alt+N / Option+N |
Mod+Shift+Enter |
Cmd+Shift+Enter / Ctrl+Shift+Enter |
Mod is the platform-aware modifier — it resolves to Meta (Cmd) on macOS and Control on other platforms.
<Command.Item value="new-file" shortcut="Mod+N" onSelect={() => createFile()}>
<span>New File</span>
<Command.Shortcut shortcut="Mod+N" />
</Command.Item>import { parseShortcut, formatShortcut } from 'modern-cmdk';
const parsed = parseShortcut('Mod+Shift+P');
// { meta: true, ctrl: false, shift: true, alt: false, key: 'p' }
// (meta is true on macOS, ctrl on Windows)
const display = formatShortcut(parsed);
// "⌘⇧P" on macOS, "Ctrl+Shift+P" on Windowsimport { detectConflicts } from 'modern-cmdk';
const shortcuts = [
{ id: 'copy', shortcut: 'Mod+C' },
{ id: 'custom-copy', shortcut: 'Mod+C' }, // Conflict!
{ id: 'paste', shortcut: 'Mod+V' },
];
const conflicts = detectConflicts(shortcuts);
// Map { "mod+c" => ["copy", "custom-copy"] }Uses Object.groupBy (ES2026) internally for efficient conflict grouping.
The parser uses RegExp.escape (ES2026) for safe pattern construction when processing shortcut strings, preventing injection of special regex characters.