Testing for Keyboard Access
When testing for keyboard access, the visual and non-visual parts of accessibility testing begin to overlap. The primary question you need to test for is whether or not all parts of the website or application can be operated entirely with the keyboard. This is very important for people with visual impairments that can’t use the mouse, people with a motor impairment, or some kind of technological limitation. This includes:
- Making sure there is a logical tab order
- Making sure that all interactive elements on a page are in the tab order
- Making sure that all interactive controls can be operated with the keyboard
- Making sure that when a user presses tab to navigate the page, focus doesn’t leave the current context, such as a modal (For modals, you must provide a way to exit with the keyboard)
- When navigating a page with a screen reader by a specific element, such as headings, the user must not be confused about where they are on the page or about the page’s structure as they go
- When tabbing around the page, each focusable element must have a noticeable focus ring around it, even if custom styled instead of using the default one provided
- If a keyboard shortcut is applied to, for example, a button, the user needs to be able to toggle it off if desired or triggered only when focused if the keyboard shortcut is a single letter, number or punctuation symbol
Logical tab order
Assistive technologies, such as screen readers and switch control, rely on the tab order to logically navigate a page or application. The focus must not move randomly around the page when they press the tab key. When that happens, the user could get lost, get overwhelmed by the sudden shift in context, or take unreasonably longer than their peers to complete an essential task. Be sure to include all interactive elements such as links, form controls and accordion buttons in the tab order.
You can learn more about this by reading guideline 2.1 of WCAG 2.2 and the Accessible Rich Internet Applications (ARIA) authoring practices.