commands.update()

Change the description or keyboard shortcut for the given command.

Syntax

js
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.

description Optional

string. A new description to set for the command.

shortcut Optional

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.

    Note: From Firefox 135, extensions can use this method to assign the F13 to F19 keys in addition to the keys supported by commands.

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.

Examples

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

js
const commandName = "my-command";

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

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

Example extensions

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
update
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 60 (Release date: 2018-05-09)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote
footnote See bug 294448
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote
footnote See bug 294448
description
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 60 (Release date: 2018-05-09)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
name
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 60 (Release date: 2018-05-09)
footnote Full support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support
shortcut
Chrome – No support
Chrome
footnote No support
Edge – No support
Edge
footnote No support
Firefox – Full support
Firefox 60 (Release date: 2018-05-09)
footnote
footnote From Firefox 74 can be set as an empty string to clear the shortcut assignment.
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

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