web_extensions / latest / api / commands.html

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.

Example extensions

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 ? 15 ?
getAll Yes 79 48 ? Yes 14 ? ? No ? 15 ?
onCommand Yes 79
48Before version 63, the onCommand listener was not treated as a handler for a user action.
? Yes 14 ? ? No ? 15 ?
reset No No 60 ? No No ? ? No ? No ?
update No No 60 ? No No ? ? No ? No ?

Note:

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

© 2005–2023 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