Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard Shortcuts in Google Chrome / Chromium Extensions

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.

like image 583
mmrobins Avatar asked Jan 22 '10 04:01

mmrobins


People also ask

How do I change keyboard shortcuts chromium?

To view or change keyboard shortcuts, select Edit > Keyboard shortcuts... from the top menu. If you make any changes in the keyboard shortcuts dialog, click Save to apply them.

Can you create keyboard shortcuts in Chrome?

Unfortunately, it isn't possible to assign a keyboard shortcut to a Chrome bookmark directly. The only built-in Google Chrome bookmarks shortcut is Ctrl + Shift + O, which opens the Chrome bookmarks manager, but you still need to click each bookmark to open it.


3 Answers

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.

like image 63
Max Shawabkeh Avatar answered Oct 05 '22 20:10

Max Shawabkeh


Just as an update it's actually being developed now:

http://developer.chrome.com/trunk/apps/commands.html

like image 26
Sean Anderson Avatar answered Oct 05 '22 21:10

Sean Anderson


Keyboard shortcuts are implemented with chrome.commands in Chrome 25 and above: developer.chrome.com/apps/commands.html.

like image 44
Sam Dutton Avatar answered Oct 05 '22 20:10

Sam Dutton