【问题标题】:Does Firefox (57.0.1) support setting from javascript a command shortcut key in a webextension?Firefox (57.0.1) 是否支持从 javascript 设置 web 扩展中的命令快捷键?
【发布时间】:2017-12-03 15:52:23
【问题描述】:

我在最近的 webextension 格式中创建了一个小扩展,它有几个命令定义为:

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

现在我想让用户能够自定义这些键盘快捷键,但是当我这样做时:

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

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

如果我检查 command.shortcut 属性,我会看到它已更改为新值,但是命令仍然只通过按旧快捷方式参与。难道我做错了什么? FF在运行时更改快捷方式是否支持?

【问题讨论】:

标签: javascript firefox keyboard-shortcuts firefox-addon-webextensions


【解决方案1】:

不幸的是,它似乎还不被支持(从 Firefox 57.0.1 开始),但是有一个开放的 bug 允许这样做:https://bugzilla.mozilla.org/show_bug.cgi?id=1303384

【讨论】:

    猜你喜欢
    • 2020-02-06
    • 1970-01-01
    • 2013-09-25
    • 2012-09-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-21
    • 1970-01-01
    相关资源
    最近更新 更多