chrome.commands 键盘快捷键不起作用 [英] chrome.commands keyboard shortcuts not working

查看:22
本文介绍了chrome.commands 键盘快捷键不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向我的 Chrome 扩展程序添加一些键盘快捷键,特别是为了允许用户使用热键打开浏览器操作/弹出窗口.我已阅读文档,并将以下代码行添加到 manifest.json 文件中:

I am trying to add some keyboard shortcuts to my Chrome extension, specifically to allow the user to use hotkeys to open up a browser action/popup. I've read the documentation, and added the following lines of code to the manifest.json file:

"commands": {
  "_execute_browser_action": {
    "suggested_key": {
      "windows": "Ctrl+Shift+Y",
      "mac": "Command+Shift+Y",
      "chromeos": "Ctrl+Shift+U",
      "linux": "Ctrl+Shift+J"
    }
  }
}

添加后,我在 chrome://extensions 中重新加载了我的扩展程序并继续尝试 Command+Shift+Y 在我的 Mac 上,什么也没发生.大约 2 个小时,我尝试在 manifest.json 中设置不同的热键组合,但没有任何效果.我从开发版 Chrome 切换到稳定版,但无济于事.当我转到 chrome://extensions 并单击右下角的键盘快捷键"按钮时,我能够手动设置热键组合,然后它就起作用了.但我不希望用户必须做那些手动工作.

After adding this, I reloaded my extension in chrome://extensions and proceeded to try out Command+Shift+Y on my Mac and nothing happened. For about 2 hours, I tried setting different hotkey combinations in manifest.json, but none worked. I switched from the dev version of Chrome to the stable version but to no avail. When I went to chrome://extensions and clicked on the 'Keyboard Shortcuts' button at the bottom right, I was able to manually set a hotkey combination and then it worked. But I don't want the user to have to do that manual work.

推荐答案

在我将快捷键设置为仅包含 Ctrl/Cmd 之一后,键盘快捷键以某种方式开始工作/Alt/Shift.所以, Alt+S 有效但 Alt+Shift+S 无效.

Somehow the keyboard shortcuts started working after I set the shortcuts to contain just one of Ctrl / Cmd / Alt / Shift. So, Alt+S worked but Alt+Shift+S did not work.

这篇关于chrome.commands 键盘快捷键不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆