Keyboard Shortcuts
Svelte Command Palette uses tinykeys for keyboard shortcut handling, supporting complex key combinations and sequences.
Shortcut Syntax
Shortcuts follow the tinykeys format:
| Syntax | Description | Example |
|---|---|---|
$mod | Meta on Mac, Ctrl on Windows/Linux | $mod+K |
Shift | Shift key | Shift+Enter |
Alt | Alt/Option key | Alt+S |
Control | Control key (explicit) | Control+C |
Meta | Meta key (explicit) | Meta+K |
Space | Single space-separated keys | G D (G then D) |
Special Keys
| Key | Syntax |
|---|---|
| Arrow keys | ArrowUp, ArrowDown, ArrowLeft, ArrowRight |
| Enter | Enter |
| Escape | Escape or Esc |
| Tab | Tab |
| Backspace | Backspace |
| Delete | Delete |
| Space | Space |
Defining Action Shortcuts
const actions = defineActions([
{
title: 'Save Document',
shortcut: '$mod+S', // Cmd+S on Mac, Ctrl+S on Windows
onRun: () => saveDocument()
},
{
title: 'Search Files',
shortcut: '$mod+Shift+F', // Multiple modifiers
onRun: () => openFileSearch()
},
{
title: 'Quick Actions',
shortcut: 'G G', // Press G twice (sequence)
onRun: () => showQuickActions()
},
{
title: 'Navigate to Dashboard',
shortcut: 'G D', // Press G then D
onRun: () => goto('/dashboard')
}
]);Custom Palette Trigger
Change the shortcut that opens the command palette:
<CommandPalette
commands={actions}
shortcut="$mod+p" // Change from Cmd+K to Cmd+P
/>Built-in Shortcuts
These shortcuts are always active when the palette is open:
↑↓
Navigate resultsEnter
Execute actionEsc
Close paletteTab
Cycle focus