Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are cross-browser and cross-OS safe keyboard shortcuts usable for web application?

I am developing a quite large web application, and it is probably a good idea to use hotkeys for some common tasks. However, I discovered that finding safe key combinations is a problem, regarding all different browsers and OSes.

For example, Chrome has such a long list of hotkeys that trying to use some kind of logical hotkeys scheme for my web application is impossible - e.g. Ctrl + 1, Ctrl + 2, Ctrl + 3, etc.

Do you have some cheat sheet of safe hotkeys which can be used in a web application and not worry about some browser or OS interference?

like image 374
Frodik Avatar asked Jul 25 '10 13:07

Frodik


People also ask

Which of the following shortcut key can be used to close Web browser?

Ctrl+N – Open a new browser window. Alt+F4 – Close the current window.


2 Answers

I wouldn't count on it. It's probably okay to listen for shortcuts that use the Alt modifier, but there's still no way to be sure a keyboard shortcut is free. Users can always install programs that listen for keyboard shortcuts, or use a browser you didn't expect.

If the shortcuts can be used only when the user is not typing in a textbox or something, it might be a better idea to just listen for keys pressed without a modifier key.

If no textbox or other GUI element is focused, then document.activeElement == document.body should be true (somebody correct me if I'm wrong).

like image 87
BernzSed Avatar answered Sep 21 '22 08:09

BernzSed


I don't think there is such a list. This may even be different for different locales.

You can try to rely on the accesskey feature of HTML: http://www.w3.org/TR/html401/interact/forms.html#adef-accesskey. This should keep the number of collisions relatively small. Though I believe the Windows browsers will offer these keys as Alt+Letter which collides with the menu bar.

Alternatively do what Google reader and Gmail do: use the letters directly without any hotkey modifier. That will only work for certain types of applications, though.

like image 34
Patrice Neff Avatar answered Sep 20 '22 08:09

Patrice Neff