commands.update()

Change the description or keyboard shortcut for the given command.

This is an asynchronous function that returns a Promise.

Syntax

browser.commands.update(
  details // object
);

Parameters

details
object. An object with the following properties:
name
string. The name of the command to update. This must match the name of an existing command, as given for example in the name property of the commands.Command object.
descriptionOptional
string. A new description to set for the command.
shortcutOptional
string. A new shortcut to set for the command. This can be:
  • an empty string to clear the shortcut.
  • a string matching the format of the commands manifest.json key to set a new shortcut key. If the string does not match this format, the function throws an error.

Return value

A Promise that will be fulfilled with no arguments when the shortcut has been updated. The promise will be rejected with an error if the command could not be found.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxOperaFirefox for Android
updateChrome No support NoEdge No support NoFirefox Full support 60Opera No support NoFirefox Android No support No
details.descriptionChrome No support NoEdge No support NoFirefox Full support 60Opera No support NoFirefox Android No support No
details.nameChrome No support NoEdge No support NoFirefox Full support 60Opera No support NoFirefox Android No support No
details.shortcutChrome No support NoEdge No support NoFirefox Full support 60
Notes
Full support 60
Notes
Notes From Firefox 74 can be set as an empty string to clear the shortcut assignment.
Opera No support NoFirefox Android No support No

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.

Examples

Updates the command named "my-command" with the given shortcut value, when the user clicks "update":

const commandName = 'my-command';

function updateShortcut() {
  browser.commands.update({
    name: commandName,
    shortcut: document.querySelector('#shortcut').value
  });
}

document.querySelector('#update').addEventListener('click', updateShortcut);

Example extensions