[英]Chrome extension keyboard command firing twice when popup is open
In the following Chrome extension, I receive a keyboard command twice when the shortcut is pressed, but only when the browser popup is open. 在以下Chrome扩展程序中,按下快捷键时两次(但仅当浏览器弹出窗口打开时)我收到两次键盘命令。 Here's how you replicate it:
复制方式如下:
Here is the code: 这是代码:
manifest.json manifest.json
{
"manifest_version": 2,
"name": "Test",
"version": "1.0",
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_popup": "popup.html"
},
"commands": {
"command": {
"suggested_key": {
"default": "Alt+Shift+S"
},
"description": "My command"
}
}
}
background.js background.js
chrome.commands.onCommand.addListener(function (command) {
console.log(command);
});
popup.html does not need to exist. popup.html不需要存在。 Why is this happening?
为什么会这样呢? I have a hack where I don't accept commands if it's been less than 50 ms since the last command, but I don't want to use a hack.
我有一个hack,如果自上一个命令以来不到50 ms,我将不接受命令,但我不想使用hack。
It looks like this is a bug with the GTK build of Chrome. 看来这是Chrome的GTK版本的错误。 You can see the bug report I filed here: https://code.google.com/p/chromium/issues/detail?id=355559
您可以在此处查看我提交的错误报告: https : //code.google.com/p/chromium/issues/detail?id=355559
This will not be fixed in the GTK build since Chrome is switching to Aura anyway. 由于Chrome仍会切换到Aura,因此在GTK版本中不会解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.