为扩展程序

时间:2017-08-21 07:16:22

标签: javascript google-chrome-extension manifest

我正在开发一个chrome扩展程序,我正在为某些操作设置快捷方式。但问题是我无法使用清单文件设置快捷方式( Alt + Z + 3

"commands": {
"fullScreen": {
  "suggested_key": {
    "default": "Alt+Z+3",
    "mac": "Alt+Z+3"
  },
  "description": "Test"
 },
 "_execute_browser_action": {
  "suggested_key": {
    "windows":"Alt+Z+3",
    "mac":"Alt+Z+3",
    "chromeos": "Alt+Z+3",
    "linux":"Alt+Z+3"
  }
 },
 "_execute_page_action": {
  "suggested_key": {
    "default": "Alt+Z+3",
    "windows": "Alt+Z+3",
    "mac": "Alt+Z+3"
  }
 }
 },

会抛出 Invalid value for 'commands[1].mac': Alt+Z+3. 等错误 但当我将快捷方式更改为( Alt + Shift + 3

  "commands": {
"fullScreen": {
  "suggested_key": {
    "default": "Alt+Shift+3",
    "mac": "Alt+Shift+3"
  },
  "description": "Toggle feature foo"
},
"_execute_browser_action": {
  "suggested_key": {
    "windows":"Alt+Shift+3",
    "mac":"Alt+Shift+3",
    "chromeos": "Alt+Shift+3",
    "linux":"Alt+Shift+3"
  }
},
"_execute_page_action": {
  "suggested_key": {
    "default": "Alt+Shift+3",
    "windows": "Alt+Shift+3",
    "mac": "Alt+Shift+3"
  }
}

},

它没有抛出任何错误。如何在扩展名中设置Alt + Z + 3的快捷方式。

1 个答案:

答案 0 :(得分:1)

你不能使用这种组合。
该计划如下:

(Alt | Ctrl) + [Shift] + <N>

其中:

  1. 需要Alt或Ctrl
  2. Shift是可选的
  3. &LT; N&GT; - 表示单个键。
    允许值:
      

    A-Z,0-9,逗号,句号,主页,结束,PageUp,PageDown,空格,插入,删除,箭头键和媒体键。

  4. 此外,您可以使用“configure commands”对话框测试组合:

    chrome://extensions/configureCommands
    

    文档:chrome.commands