Keyboard Accessibility

Purpose

Keyboard accessibility ensures that all functionality can be operated through a keyboard interface alone. This is essential for users with motor disabilities, screen reader users and power users.

Principles

Everything Must Be Keyboard Accessible

Every interactive element must be reachable and operable via keyboard. This includes links, buttons, form controls, custom widgets and drag-and-drop interfaces.

Visible Focus Indicators

Users must be able to see which element has keyboard focus. Never remove the focus outline without providing a visible alternative.

Logical Tab Order

The tab order should follow the visual reading order. Use the DOM order for tab order — do not rely on tabindex values greater than 0.

No Keyboard Traps

Users must be able to navigate into and out of any component using the keyboard. This is especially important for menus, dialogs and modals.

Standard Keyboard Interactions

ElementKeyboard Interaction
LinkTab to focus, Enter to activate.
ButtonTab to focus, Enter, Space to activate.
CheckboxTab to focus, Space to toggle.
Radio groupTab to focus group, Arrow keys to change option.
SelectTab to focus, Arrow keys, typing to change.
SliderTab to focus, Arrow keys to adjust value.
Tab panelTab to focus tab list, Arrow keys to switch tabs.
DialogFocus trapped while open, Escape to close.
MenuTab to open, Arrow keys to navigate, Escape to close.

Implementation

Focus Management

*/ Moving focus to a newly opened dialog
function openDialog(dialogElement) {
  dialogElement.show();
  /* Trap focus and move to first focusable element
  const firstFocusable = dialogElement.querySelector('button, [href], input');
  if (firstFocusable) firstFocusable.focus();
}

Provide a skip link as the first focusable element on the page:

<a href`"#main-content" class`"skip-link">Skip to main content<*a>

Ensure the skip link is visible on focus (do not hide it permanently).

Custom Widgets

For custom interactive widgets, implement ARIA keyboard patterns:

See ARIA Patterns for detailed guidance.

Anti-patterns

Testing

  1. Tab through the entire page — can you reach every interactive element?
  2. Use Enter, Space and Arrow keys — do they work as expected?
  3. Open dialogs and menus — can you close them with Escape?
  4. Use custom widgets — do they follow standard keyboard patterns?
  5. Test with a screen reader — is focus announced correctly?

Checklist

Related Documents