Which key to bind to avoid conflict with native browser shortcuts?

Every browser has different native keyboard shortcuts. Which ones are free / safe to use if we want to add some spicy stuff to our web-app?

Additional information:

I don’t especially need to target every browser. The five majors one are sufficient. For example, Opera commonly uses Ctrl + key, leaving almost all Alt + key “free to bind”.

As different browsers use a different main modifier (Ctrl in Opera), I can easily imagine using a different key to bind shortcuts to. i.e Alt + Key in Opera, Ctrl + Key in browser 2, Ctrl + Alt in browser 3, etc.

For a pragmatic solution, copy Google. They have keyboard shortcuts in Gmail (and probably other products) that do a pretty good job of avoiding browser shortcuts.

If you only need keyboard shortcuts outside of form elements having focus, I would use plain letters (no Ctrl / Alt / Shift / etc.). Regular characters are only important to the browser if a form element has focus. Otherwise they’re ignored.

For example, if you have paginated content, P could be previous and N could be next.

(Not sure if this would completely solve your problem because this won’t work when a form element has focus.)

Based on your comment (the focus will be inside a textarea), I would suggest a single letter chosen for each action with a different Ctrl / Alt / Shift combination per browser. Most people only use one browser, so for each user to learn just their own combination isn’t a big deal.

So, for example, Ctrl + Alt + N in one browser might be the same as Alt + N in another.

Read More:   Close a SELECT dropdown list programmatically with Javascript/jQuery

The first thing I would test, though, is Shift, because most built-in combinations don’t use one, but I don’t know if the combos are always case-insensitive. Also watch out for OS-specific combos.

Here’s what I’ve found mostly available so far:

OS X    - FF/Safari/Chrome - ctrl-[key]
Windows - FF/IE            - ctrl-alt-[key]

The short answer is:

Disappointingly, our research
discovered that all but 3 keys were
previously “claimed” by one technology
or the other:

* AccessKey / (slash)
* AccessKey (backslash)
* AccessKey ] (right square bracket)

This is explain in this article:

This wikipedia article give a good general introduction into this subject:

My recommendation is to change it depending on the browser. The fact is, there are so many browsers out there, I think you’d be hard-pressed to come up with a shortcut scheme that won’t break on at least one popular browser.

You could change the shortcut setup based on the browser and also change the instructions specifying which shortcuts to used based on the user’s browser.

Ideally, you’d make the shortcut as intuitive as possible (Ctrl + X, or Alt + X etc) without actually interfering with the browser.

Edit: Alternatively if you’re comfortable overriding default functionality, maybe use this: http://www.openjs.com/scripts/events/keyboard_shortcuts/

When you specify a shortcut with it, the browser will ignore that shortcut, and you can use it in your app (like gmail does with Ctrl + S, for example).

For Mac users you want to definitely go with Ctrl as Alt is used to type many different characters and command is the default action key which the browsers use. I’d avoid combos that use basic emacs style shortcuts as well (some users use them like Ctrl + K which SO manages to screw up 😉 though these are less known and so possibly usable.

Read More:   Accessing localStorage from a webWorker

For Windows it’s more complicated – and I don’t have a win box to test it myself.

Screen readers (JAWS, NVDA, …) already use the whole keyboard, dead keys included (I’m exagerating a little but it’s competing with Adobe Photoshop in terms of number of keyboard shortcuts used).

So if you want to support screen readers and other assistive technologies, you should use ARIA and especially role=”application”. That’ll avoid conflicts between your application and the default functioning mode of screen readers in web pages. One drawback is that you’ve got dozens and dozens of pages to read …

Introduction à WAI/ARIA (traduction en français) (our common native language, isn’t it SDZ/zC? ;))

EDIT: One of the way to solve conflicts is letting the user define and modify his own shortcuts.

I don’t know for certain that this list is exhaustive but you will find a good list of shortcuts for the different browsers here:


Hope this helps.

To add to Matt S‘s recommendation to use plain letter keys (if that fit’s your use case), you can use an event.target.matches() check to ensure the plain letter hotkey isn’t allowed when the user is focused on an input or textarea:

document.addEventListener('keydown', e => {
  if (e.target.matches('input, textarea')) {
    console.log('typing in input or textarea');

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Similar Posts