TL;DR: Whatever you can see or do with a mouse or touch gesture, you need to be able to see and do with a keyboard. SC 2.1.1.
This issue focuses on specifically on Guideline 2.1 Keyboard Accessibility but includes overlapping guidelines and success criteria. Additionally, keyboard interactions must follow the pre-existing patterns defined by the browser, first, and our component libraries, second (with the caveat that the WCAG is the final authority).
This issue should be utilised both as individual features are being implemented and towards the end, before release. It should ultimately be one of the last issues resolved.
Keyboard basics
Sources: WebAim | MagentaA11y
| Key |
Interaction |
Notes |
Tab / Shift + Tab |
navigate forwards/backwards |
Keyboard focus indicators must be present. Navigation order should be logical and intuitive. |
Enter |
activates links and buttons |
Ensure elements with ARIA role="button" can be activated with both Enter and Spacebar. |
Spacebar |
activates buttons, interacts with form elements or scroll by page |
The space bar will, by default, scroll the page, but only if an interactive control that allows space bar input is not focused. |
↑/↓ / ←/→ |
interact with form fields or scroll page vertically/horizontally |
Horizontal scrolling within the page should be minimized. |
Browser-defined interactions
The browser already contains a number of standard patterns for keyboard interactions. As a general rule, these patterns should not be overridden.
Most common interactions
Source: WebAim
| Element |
Keystrokes |
Notes |
| Link |
Enter - activate the link |
|
| Button |
Enter or Spacebar - activate the button |
Ensure elements with ARIA role="button" can be activated with both key commands. |
| Checkbox |
Spacebar - check/uncheck a checkbox |
Users can typically select zero, one, or multiple options from group of checkboxes. |
| Radio buttons |
Tab - once to navigate into the group of radio buttons and once to navigate out of the group of radio buttons
↑/↓ or ←/→ - navigate between options Spacebar- select the focused option (if not selected) |
Users can select only one option from a group of radio buttons. |
| Select (native dropdown) menu |
↑/↓ - navigate between options
Spacebar - expand
Enter/Esc - select option and collapse |
You can also filter or jump to options in the menu as you type letters. |
| Autocomplete |
Type to begin filtering
↑/↓ - navigate to an option
Enter - select an option |
|
| Dialog |
Esc - close |
Modal dialogs should maintain keyboard focus. Non-modal dialogs should not, and should close automatically when they lose focus. When a dialog closes, focus should usually return to the element that opened the dialog. |
| Slider |
↑/↓ or ←/→ - increase or decrease slider value
Home/End - beginning or end |
For double-headed sliders (to set a range), Tab/Shift + Tab should toggle between each end.In some sliders PageUp/PageDown can move by a larger increment (e.g., by 10%). |
| Menu bar |
↑/↓ - previous/next menu option
Enter - expand the menu (optional) and select an option.
←/→ - expand/collapse submenu |
A menu bar dynamically changes content within an application. Links that utilize Tab/Enter are NOT menu bars. |
| Tab panel |
Tab - once to navigate into the group of tabs and once to navigate out of the group of tabs
↑/↓ or ←/→ - choose and activate previous/next tab. |
This is for 'application' tabs that dynamically change content within the tab panel. If a menu looks like a group of tabs, but is actually a group of links to different pages, Tab and Enter are more appropriate. |
| 'Tree' menu |
↑/↓ - navigate previous/next menu option
←/→ - expand/collapse submenu, move up/down one level. |
|
How to Test
Configuration
Set viewport to a width of 320px as it is not uncommon for people to pair an external keyboard with their phones and tablets. (Sources: WebAim, Yale)
General
The overarching requirements regardless of feature design or individual elements:
Individual Components
For components that are not listed in the Browser-defined interactions, you can check against the following libraries:
Bootstrap for Storefront
Meteor for Admin
The following scenarios may become relevant depending on which components you are testing within your feature:
This issue focuses on specifically on Guideline 2.1 Keyboard Accessibility but includes overlapping guidelines and success criteria. Additionally, keyboard interactions must follow the pre-existing patterns defined by the browser, first, and our component libraries, second (with the caveat that the WCAG is the final authority).
This issue should be utilised both as individual features are being implemented and towards the end, before release. It should ultimately be one of the last issues resolved.
Keyboard basics
Sources: WebAim | MagentaA11y
Tab/Shift + TabEnterrole="button"can be activated with bothEnterandSpacebar.Spacebar↑/↓/←/→Browser-defined interactions
The browser already contains a number of standard patterns for keyboard interactions. As a general rule, these patterns should not be overridden.
Most common interactions
Source: WebAim
Enter- activate the linkEnterorSpacebar- activate the buttonrole="button"can be activated with both key commands.Spacebar- check/uncheck a checkboxTab- once to navigate into the group of radio buttons and once to navigate out of the group of radio buttons↑/↓or←/→- navigate between optionsSpacebar- select the focused option (if not selected)↑/↓- navigate between optionsSpacebar- expandEnter/Esc- select option and collapse↑/↓- navigate to an optionEnter- select an optionEsc- close↑/↓or←/→- increase or decrease slider valueHome/End- beginning or endTab/Shift + Tabshould toggle between each end.In some slidersPageUp/PageDowncan move by a larger increment (e.g., by 10%).↑/↓- previous/next menu optionEnter- expand the menu (optional) and select an option.←/→- expand/collapse submenuTab/Enterare NOT menu bars.Tab- once to navigate into the group of tabs and once to navigate out of the group of tabs↑/↓or←/→- choose and activate previous/next tab.TabandEnterare more appropriate.↑/↓- navigate previous/next menu option←/→- expand/collapse submenu, move up/down one level.How to Test
Configuration
Set viewport to a width of
320pxas it is not uncommon for people to pair an external keyboard with their phones and tablets. (Sources: WebAim, Yale)General
The overarching requirements regardless of feature design or individual elements:
Tab/Shift+Tab, no interactive elements are missed SC 2.4.7Individual Components
For components that are not listed in the Browser-defined interactions, you can check against the following libraries:
Bootstrap for Storefront
Meteor for Admin
The following scenarios may become relevant depending on which components you are testing within your feature: