Change the description or keyboard shortcut for the given command.
This is an asynchronous function that returns a Promise.
browser.commands.update( details // object );
detailsobject. An object with the following properties:namestring. 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: commands manifest.json key to set a new shortcut key. If the string does not match this format, the function throws an error.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.
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
update |
No |
No |
60 |
? |
No |
No |
? |
? |
No |
? |
? |
? |
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);
© 2005–2021 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/update