Connect+Documentation
ExtensionsAPI reference

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.

  1. Declare the command in the manifest:
    "commands": { "toggle-thing": { "suggested_key": { "default": "Ctrl+Shift+Y" }, "description": "Toggle" } }
  2. Handle it:
    connect.commands.onCommand((name) => name === 'toggle-thing' && toggle());
  3. Reserve _execute_action if 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

  1. Call it to show the user their current shortcuts (name, description, resolved key).

Signatureconnect.commands.getAll() · ReturnsPromise<{ name, description, shortcut }[]>.

Events

commands.onCommand(cb)

Fires when the user presses one of your shortcuts. Wakes a suspended background.

How to use it

  1. Subscribe in the background.
  2. Branch on the commandName.
  3. Note _execute_action does not arrive here — it opens the popup.

PayloadcommandName (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, and getAll reports what actually fires — so display shortcuts from getAll, never from your own manifest.

On this page