Agent Wranglers

Accessibility Required

Never take over single keys

Never use a shortcut that is a single letter, number or symbol key unless people can turn it off or remap it. This is WCAG criterion 2.1.4 (A).

How to do it

Make shortcuts need a modifier, such as Ctrl or Alt. Or make them work only while their widget has focus. Never act on a single key press while focus is in a text field.

Example

<script>
  document.addEventListener('keydown', event => {
    if (event.key === 'k' && (event.ctrlKey || event.metaKey)) openSearch();
  });
</script>

How to check

A browser test presses each letter and digit with focus on the page body. Nothing changes on the page.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers website playbook: https://agentwranglers.se/playbook/website/accessibility/character-key-shortcuts.