Keyboard Shortcuts

Svelte Command Palette uses tinykeys for keyboard shortcut handling, supporting complex key combinations and sequences.

Shortcut Syntax

Shortcuts follow the tinykeys format:

SyntaxDescriptionExample
$modMeta on Mac, Ctrl on Windows/Linux$mod+K
ShiftShift keyShift+Enter
AltAlt/Option keyAlt+S
ControlControl key (explicit)Control+C
MetaMeta key (explicit)Meta+K
SpaceSingle space-separated keysG D (G then D)

Special Keys

KeySyntax
Arrow keysArrowUp, ArrowDown, ArrowLeft, ArrowRight
EnterEnter
EscapeEscape or Esc
TabTab
BackspaceBackspace
DeleteDelete
SpaceSpace

Defining Action Shortcuts

actions.ts
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:

Custom Trigger
<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 results
Enter
Execute action
Esc
Close palette
Tab
Cycle focus