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:

  1. install following chrome extension.
  2. navigate chrome extensions page
  3. scroll bottom , click "keyboard shortcuts"
  4. set shortcut extension alt+shift+s
  5. in extensions page, click "background page" link extension open background page console.
  6. hit alt+shift+s. you'll see "command" being logged once.
  7. now open browser popup should have appeared when extension installed. hit alt+shift+s.
  8. 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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -