Movatterモバイル変換


[0]ホーム

URL:


  1. Mozilla
  2. Add-ons
  3. Browser extensions
  4. JavaScript APIs
  5. commands
  6. commands.update()

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 thename property of thecommands.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 thecommands 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 theF13 toF19 keys in addition to the keys supported bycommands.

Return value

APromise 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

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp