1.4. Allow scripts to be controlled using both the mouse and the keyboard

Whenever a script is controlled by the mouse, it must also be possible to control it with the keyboard, and vice versa.

In other words, each time the mouse can be used to control a script, using an element such as a link or button, the user must be able to:

  • Reach the script using the keyboard.
  • Control the script using the keyboard once the focus is set on the corresponding element.

Warning

Whenever possible, use generic event listeners rather than specific ones for a keyboard button. For example, use onfocus/onblur rather than onkeydown.

This is important because keyboard shortcuts are not always the same on different systems and browsers. For example, in the Opera browser, the Shift key, together with the arrow keys, allows the user to navigate from one link to another. However, most other browsers use the Tab key for this shortcut.

Note

It is very important to avoid keyboard traps. Keyboard traps block a user who navigates with the keyboard, because they prevent interaction with specific zones on the page.

Keyboard traps arise when a user is blocked on a page when navigating with a keyboard:

  • Either because an element prevents the user from moving the focus to the previous or next interactive element.
  • Or because an element does not let the user move on from the current focus, once it is applied to an element.

Each time that scripts are used on a page, make sure they do not contain keyboard traps by running a simple test on the interface with the keyboard.

notices/interfaces-riches-javascript/permettre-le-controle-des-scripts-a-la-fois-a-la-souris-et-au-clavier.txt · Last modified: 02 December 2013 at 09:53 by Sébastien Delorme (Atalan)
 

Project coordinated by Atalan.

In partnership with:

Observers: