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 must match the format given in the documentation for the commands manifest.json key. If it does not match this format, the function will throw an error.

Return value

A Promise that will be fulfilled with no arguments when the shortcut has been reset. 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
Basic supportChrome No support NoEdge No support NoFirefox Full support 60Opera No support NoFirefox Android No support No

Legend

Full support  
Full support
No support  
No support

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

Document Tags and Contributors

Contributors to this page: ericpromislow, wbamberg
Last updated by: ericpromislow,