javascript - Chrome extension keyboard command firing twice when popup is open -
in following chrome extension, receive keyboard command twice when shortcut pressed, when browser popup open. here's how replicate it:
- install following chrome extension.
- navigate chrome extensions page
- scroll bottom , click "keyboard shortcuts"
- set shortcut extension alt+shift+s
- in extensions page, click "background page" link extension open background page console.
- hit alt+shift+s. you'll see "command" being logged once.
- now open browser popup should have appeared when extension installed. hit alt+shift+s.
- go background page console , you'll see "command" logged twice.
here code:
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
chrome.commands.oncommand.addlistener(function (command) { console.log(command); });
popup.html not need exist. why happening? have hack don't accept commands if it's been less 50 ms since last command, don't want use hack.
it looks bug gtk build of chrome. can see bug report filed here: https://code.google.com/p/chromium/issues/detail?id=355559
this not fixed in gtk build since chrome switching aura anyway.
Comments
Post a Comment