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

查看:281
本文介绍了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天全站免登陆