Frank
Frank

Reputation: 51

Does Firefox (57.0.1) support setting from javascript a command shortcut key in a webextension?

I've created a little extension in the recent webextension format, it has a couple of commands defined as:

  "commands": {
    "mycommand1": {
      "suggested_key": {
        "default": "Ctrl+Shift+K",
        "mac": "MacCtrl+Shift+K",
        "linux": "Ctrl+Shift+K",
        "windows":"Ctrl+Shift+K"
      },
      "description": "do something 1"
    }

now I would like to give the ability to the users to customize these keyboard shortcuts, however when i do:

var getCommands = browser.commands.getAll();
getCommands.then(setCommandsSettings);

function setCommandsSettings(commands){
    commands.forEach(function(command) {
        if(command.name=="mycommand1"){
          command.shortcut="MacCtrl+Shift+L";
        }
      });
}

If I check the command.shortcut property I see that it has been changed to the new value, however the commands still gets involved only by pressing the old shortcut. Am I doing something wrong? Is it supported by FF changing the shortcut at runtime?

Upvotes: 1

Views: 108

Answers (1)

Frank
Frank

Reputation: 51

Unfortunately it seems that it's not yet supported (as of Firefox 57.0.1) however there's a bug open for a enhancement allowing this: https://bugzilla.mozilla.org/show_bug.cgi?id=1303384

Upvotes: 1

Related Questions