UPDATE (5/24/2013): You can use the new chrome.commands
API, which provides built-in framework support for keyboard commands.
Original answer follows:
Step 1: Use a content script to bind a keypress listener to every page.
// in the content script, listen for Crtl+Shift+E (upper or lowercase) document.documentElement.addEventListener("keypress", function(event) { if((e.keyCode == 69 || e.keyCode == 101) && e.ctrlKey && e.shiftKey) { // do something (step 2, below) } }, true);
Step 2: For action outside of the content script, use message passing to notify the background page that the shortcut key has been pressed and it should perform some action.
Step 3: The background page does some action. It's currently not possible (and will likely never be possible) to open a Browser Action popup programatically, but you could send an interactive desktop notification, open a new tab, or do a lot of other things.
Read full article from Activate extension via short cut key - Stack Overflow
No comments:
Post a Comment