Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Extension Commands and Omnibox: Keyboard Shortcuts, Manifest, and Scope

How browser extension commands and omnibox keywords work: manifest setup, key rules, handlers, action shortcuts, and platform limits.

This page summarizes Chrome extension documentation on two ways users invoke features without opening the toolbar popup: the Commands API (browser.commands / chrome.commands) for keyboard shortcuts, and the Omnibox API for address-bar keywords. Both are declared in manifest.json and handled from a background service worker (Manifest V3) or background script.

Commands API: what keyboard shortcuts do in an extension

Section titled “Commands API: what keyboard shortcuts do in an extension”

The Commands API lets an extension register key combinations that run extension logic—for example opening the action or sending a named command to the background context.

Use the commands API to add keyboard shortcuts that trigger actions in your extension, for example, an action to open the browser action or send a command to the extension.

— Chrome, browser.commands

Each named command is a property under the manifest’s commands object. The property name is the command name passed to your listener. Command objects support:

Property Role
suggested_key Optional default shortcut (string for all platforms, or object with default, windows, mac, linux, chromeos)
description Short label in chrome://extensions/shortcuts; required for standard commands, ignored for action commands
global Optional; when true, shortcut can fire when Chrome does not have focus (with limits below)

If suggested_key is omitted, the command ships unbound until the user assigns a key in chrome://extensions/shortcuts.

The Commands API allows extension developers to define specific commands, and bind them to a default key combination. Each command an extension accepts must be declared as properties of the “commands” object in the extension’s manifest.

— Chrome, browser.commands — Concepts and usage

An extension may declare many commands but at most four suggested_key defaults. Users can bind additional shortcuts in the shortcuts UI.

The manifest must list the API permission key commands (Manifest).

manifest.json commands: minimal declaration and listener

Section titled “manifest.json commands: minimal declaration and listener”

At minimum, declare a command and listen in the service worker:

"commands": {
"inject-script": {
"suggested_key": "Ctrl+Shift+Y",
"description": "Inject a script on the page"
}
}
browser.commands.onCommand.addListener((command) => {
console.log(`Command "${command}" triggered`);
});

Step-by-step patterns appear in Respond to commands and the basic-command samples in browser.commands.

Key combination requirements: which shortcuts are valid

Section titled “Key combination requirements: which shortcuts are valid”

Supported key tokens are case-sensitive; wrong casing causes a manifest parse error at install time. Allowed groups include A–Z, 0–9, navigation keys (Home, PageDown, arrows, and similar), media keys (MediaPlayPause, and similar), and modifiers Ctrl, Alt, Shift, plus macOS-only Command, Option, MacCtrl, and ChromeOS-only Search (Supported Keys).

Rules that most implementations get wrong:

Extension command shortcuts must include either Ctrl or Alt.

— Chrome, Key combination requirements

  • Ctrl+Alt combinations are not allowed (AltGr conflicts).
  • Modifiers cannot combine with media keys.
  • On macOS, manifest Ctrl is converted to Command; use MacCtrl in the mac shortcut to mean the physical Control key. MacCtrl on non-mac platforms fails validation.
  • On macOS, Command or MacCtrl can stand in for Ctrl, and Option for Alt.
  • Shift is optional everywhere; Search is optional on ChromeOS only.
  • OS and browser shortcuts (for example window management) always win; extensions cannot override them.

Platform-specific suggested_key example from the reference:

"run-foo": {
"suggested_key": {
"default": "Ctrl+Shift+Y",
"mac": "Command+Shift+Y"
},
"description": "Run \"foo\" on the current page."
}

Action commands: _execute_action without onCommand

Section titled “Action commands: _execute_action without onCommand”

Reserved command names wire shortcuts to the extension action (toolbar button), not to onCommand:

Manifest V3 Manifest V2
_execute_action _execute_browser_action, _execute_page_action

The _execute_action (Manifest V3), _execute_browser_action (Manifest V2), and _execute_page_action (Manifest V2) commands are reserved for the action of trigger your action, browser action, or page action respectively. These commands don’t dispatch command.onCommand events like standard commands.

— Chrome, Action commands

The shortcut runs the same path as clicking the action—for example opening the popup or firing action.onClicked when there is no popup (Inject scripts into the active tab). If you need code when a popup opens, use DOMContentLoaded inside the popup script instead of onCommand.

Command scope: browser-focused vs global shortcuts

Section titled “Command scope: browser-focused vs global shortcuts”

By default, commands work only while Chrome has focus.

By default, commands are scoped to the Chrome browser. This means that when the browser does not have focus, command shortcuts are inactive.

— Chrome, Scope

Set "global": true on a command so it can fire when Chrome is in the background (since Chrome 35). Constraints:

Note: ChromeOS does not support global commands.

— Chrome, Scope

Keyboard shortcut suggestions for global commands are limited to Ctrl+Shift+[0..9].

— Chrome, Scope

Users may remap global shortcuts at chrome://extensions/shortcuts.

Register one listener and branch on the command name (Respond to commands):

browser.commands.onCommand.addListener((command) => {
if (command !== "open-tab") return;
browser.tabs.create({ url: "https://developer.chrome.com" });
});

The callback type is (command: string, tab?: tabs.Tab) => void (Parameters). A full tab-cycling example lives under Design the user interface — Commands (flip-tabs-forward / flip-tabs-backwards).

Manifest V2 samples use chrome.commands instead of browser.commands (chrome.commands); behavior matches the MV3 reference for manifest fields and key rules.

If another extension already uses a shortcut, a newly installed extension may not get that binding.

If an extension attempts to register a shortcut that is already used by another extension, the second extension’s shortcut won’t register as expected.

— Chrome, Verify commands registered

On first install only, call browser.commands.getAll() and treat an empty shortcut string as unassigned; update UI so users know to open the shortcuts page (Verify commands registered). After install, respect deliberate unbinding by the user.

getAll() returns name, description, and shortcut per command. _execute_action is not included in that list in the MV2 note on the same pattern (Verify commands registered — MV2).

Omnibox API: address-bar keywords vs commands

Section titled “Omnibox API: address-bar keywords vs commands”

Commands answer “run this with a key combo.” The omnibox answers “start typing in the address bar with my keyword.”

The omnibox API allows you to register a keyword with Google Chrome’s address bar, which is also known as the omnibox.

— Chrome, browser.omnibox

When the user enters your keyword, interaction is routed to the extension: keystrokes can drive suggestions; accepting a suggestion notifies the extension.

Manifest requirements:

Typical flow after the user confirms input (onInputEntered):

browser.omnibox.onInputEntered.addListener((text) => {
const newURL = `https://www.google.com/search?q=${encodeURIComponent(text)}`;
browser.tabs.create({ url: newURL });
});

The Omnibox New Tab Search pattern uses keyword nt. Overview: User interface components — Omnibox and Design the user interface — Omnibox.

Platform notes: ChromeOS and Googlebook OS

Section titled “Platform notes: ChromeOS and Googlebook OS”

On Googlebook OS, extension shortcuts follow the same rules as Chrome on Linux for manifest purposes:

Chrome reads the linux entry of suggested_key on Googlebook OS, so shortcuts defined under chromeos don’t apply. Search key combinations don’t work either, as there is no “Search” key on Googlebook OS devices.

— Chrome, Adapt your extension for Googlebook OS

Put Googlebook defaults under linux, not chromeos, and do not rely on Search as a modifier there. Remember ChromeOS also blocks global commands and does not support the Search modifier on Googlebook hardware.

  • Expecting onCommand for _execute_action instead of action/popup handlers.
  • More than four default suggested_key entries.
  • Invalid keys (Ctrl+Alt+…, media keys with modifiers, wrong key capitalization).
  • Using MacCtrl outside the mac shortcut object.
  • Running collision checks on every startup and overwriting user shortcut choices.
  • Omnibox keyword without a 16×16 icon, or assuming the bar shows your color icon (Chrome grayscales it).
  • Assuming chromeos shortcuts apply on Googlebook OS (use linux).
  1. Load the unpacked extension and open chrome://extensions/shortcuts. Confirm each command shows your description and whether defaults or conflicts appear, per browser.commands.

  2. Press each standard command shortcut and verify the service worker receives the expected name in onCommand (Respond to commands).

  3. For _execute_action, press the shortcut and confirm the popup or action.onClicked path runs without calling onCommand (Inject scripts into the active tab).

  4. If you use a global command, test with Chrome unfocused (not on ChromeOS) and confirm the binding is Ctrl+Shift+[0-9] unless the user remapped it (Scope).

  5. For omnibox, type your keyword in the address bar, confirm the grayscale icon appears, and complete an action via onInputEntered (Trigger actions from the omnibox).

  1. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact wording you are asking about so it can be corrected.