files/en-us/mozilla/add-ons/webextensions/api/commands/update/index.md
Change the description or keyboard shortcut for the given command.
browser.commands.update(
details // object
);
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 {{WebExtAPIRef("commands.Command")}} object.description {{optional_inline}}
string. A new description to set for the command.shortcut {{optional_inline}}
string. A new shortcut to set for the command. This can be:
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
F13toF19keys in addition to the keys supported bycommands.
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.
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);
{{WebExtExamples}}
{{Compat}}