connect.commands
Manifest-declared keyboard shortcuts and the onCommand event.
Keyboard shortcuts. No capability — they're your own declared shortcuts. The browser fires them when the user presses the shortcut while a page in your profile (or the shell chrome) is focused. A Ctrl / Alt / ⌘ modifier is always required, so plain typing is never intercepted.
- Capability: none
- Namespace:
connect.commands
Walkthrough
Add a "toggle" shortcut.
- Declare the command in the manifest:
"commands": { "toggle-thing": { "suggested_key": { "default": "Ctrl+Shift+Y" }, "description": "Toggle" } } - Handle it:
connect.commands.onCommand((name) => name === 'toggle-thing' && toggle()); - Reserve
_execute_actionif you want a shortcut that opens your popup instead.
suggested_key may carry per-platform keys (default / mac / windows / linux);
Ctrl maps to ⌘ on macOS (Chrome's convention).
Methods
commands.getAll()
List your commands and their resolved shortcuts on this platform.
How to use it
- Call it to show the user their current shortcuts (name, description, resolved key).
Signature — connect.commands.getAll() · Returns — Promise<{ name, description, shortcut }[]>.
Events
commands.onCommand(cb)
Fires when the user presses one of your shortcuts. Wakes a suspended background.
How to use it
- Subscribe in the background.
- Branch on the
commandName. - Note
_execute_actiondoes not arrive here — it opens the popup.
Payload — commandName (string).
connect.commands.onCommand((name) => {
if (name === 'toggle-thing') toggle();
});Notes
- Shortcuts fire while a page in your profile is focused or while the shell chrome (address bar, tab strip) is — in the latter case they act for the profile the shell is showing. On the profiles dashboard, no profile is active, so nothing fires.
- Users can re-bind or disable any command from Extensions → Shortcuts…; the
override wins over your
suggested_key, andgetAllreports what actually fires — so display shortcuts fromgetAll, never from your own manifest.