views:

1879

answers:

1

I've created a basic extension for Google Chrome to change the behavior of which tab is selected when you close a tab so that the selected tab is the last one you had selected instead of just the one before the tab you closed.

I want to add keyboard shortcuts, and I've found a way to do that using jquery and jquery hotkeys, but the problem I'm finding is that the keyboard shortcuts only work once a page is loaded. So for example, if you open a new tab without going anywhere, the shortcut keys don't work because the javascript only loads when a page is on the screen. Same problem if you have the extensions page open in a tab.

Does anyone know of a better way to do keyboard shortcuts in Chrome extensions? I've been looking through the extensions documentation, but I haven't found anything that looks promising.

+4  A: 

Unfortunately there's no way to hook into global hotkeys. The best you can do is add a window event keypress listener.

Source: a Chromium developer post on the chromium-extensions group.

Max Shawabkeh
I was hoping this wasn't the case, but it seems like for now there isn't a way to do keyboard shortcuts without interacting with the loaded web page. I'll update with an answer if I find anything better.
mmrobins
Hopefully by the next release version, they will implement Global shortcuts. The current way I do it is with Window Events. Feel free to take a look at my reload all tabs shortcut extension:http://github.com/mohamedmansour/chrome-extensions/tree/master/reload_all_tabs/
Mohamed Mansour