commands

Listen for the user executing commands that you have registered using the commands manifest.json key.

Types

commands.Command
Object representing a command. This contains the information specified for the command in the commands manifest.json key.

Functions

commands.getAll

Gets all registered commands for this extension.

commands.reset

Reset the given command's description and shortcut to the values given in the manifest key.

commands.update

Change the description or shortcut for the given command.

Events

commands.onCommand
Fired when a command is executed using its associated keyboard shortcut.

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
Command
Yes
79
48
?
Yes
14
?
?
No
?
?
?
getAll
Yes
79
48
?
Yes
14
?
?
No
?
?
?
onCommand
Yes
79
48
Before version 63, the onCommand listener was not treated as a handler for a user action.
?
Yes
14
?
?
No
?
?
?
reset
No
No
60
?
No
No
?
?
No
?
?
?
update
No
No
60
?
No
No
?
?
No
?
?
?

Example extensions

Note:

This API is based on Chromium's chrome.commands API.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/commands