Command interface
Commands are defined using theHotKeyPadCommand interface:
A unique identifier for the command. Used internally to track and manage commands.
The display name shown in the command palette. This text is searchable and should clearly describe the action.
An optional icon to display next to the command. Can be:
- A Simple Icons slug (e.g.,
"github","twitter") - Custom HTML (SVG, img tag, or icon font)
- Leave empty for no icon
The keyboard shortcut to trigger this command. Supports up to 2 keys (modifier + letter).Examples:
"Ctrl+S", "Cmd+K", "Alt+N"Avoid browser/system reserved hotkeys like Ctrl+T, Ctrl+N, or Ctrl+W
Optional group name to organize commands. Commands with the same section value appear together under a labeled group.If omitted, commands are placed in an “Unlisted” section without a header.
The function executed when the command is triggered. Receives the HotkeyPad instance element as a parameter.
Creating commands
Define your commands as an array and pass them tosetCommands():
Organizing with sections
Sections help group related commands together. Commands with the samesection value appear under a labeled heading:
- Edit section with Cut and Copy
- Preferences section with Open settings
Command validation
HotkeyPad validates commands when you callsetCommands(). The following rules apply:
Validation rules
Validation rules
- The commands array cannot be empty
- Each command must have
id,title,hotkey, andhandler(all non-empty) - Hotkeys must be valid (no reserved browser shortcuts)
- Hotkeys support maximum 2 keys (modifier + letter)
- Icons, if provided, must be strings
Invalid commands throw an error with a descriptive message to help you fix the issue.
Handler execution
When a command is triggered (via hotkey or selection), HotkeyPad:- Executes the handler function after a 200ms delay
- Passes the HotkeyPad instance element to the handler
- Automatically closes the command palette