# Accesskey attribute values must be unique.

> Canonical HTML version: https://rocketvalidator.com/accessibility-validation/accesslint/0.16/keyboard-accessible/accesskeys
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `accesskey` attribute assigns a keyboard shortcut to an HTML element, allowing users to activate or focus it by pressing a key combination. When two or more elements on the same page share the same `accesskey` value, the browser cannot reliably determine which element to activate. In most browsers, only the first element with the duplicated value receives focus, and the rest are silently ignored. This makes the shortcut unreliable and confusing.

Keyboard-only users and screen reader users are the most affected. These users often depend on keyboard shortcuts to navigate a page efficiently. If a duplicated `accesskey` sends focus to the wrong element, or if an expected shortcut appears to do nothing, it can block users from reaching content or completing tasks. Sighted keyboard users may also struggle to understand why a documented shortcut is not working as expected.

This rule relates to WCAG Success Criterion 4.1.1 Parsing (Level A) and the broader principle that user interface components must behave predictably. Duplicate `accesskey` values create ambiguous markup that browsers interpret inconsistently.

## How to fix it

Audit the page for all elements that use the `accesskey` attribute and make sure every value is unique. If two elements currently share the same key, change one of them to a different character.

A few practical considerations:

- `accesskey` shortcuts can conflict with built-in browser shortcuts and screen reader key combinations. For example, `accesskey="s"` may collide with the browser's "Save" shortcut. Use `accesskey` values sparingly, and prefer characters that are less likely to conflict (digits are sometimes safer than letters).
- If the shortcut is not truly necessary, removing the `accesskey` attribute entirely is a valid fix. Navigation landmarks, skip links, and proper heading structure often provide a better experience than access keys.
- When access keys are used, document them somewhere on the page so users know they exist.

## Examples

### Duplicate `accesskey` values (incorrect)

In this example, both the search field and the submit button use `accesskey="s"`. The browser will typically send focus to the search field and ignore the button's shortcut.

```html
<label for="search">Search</label>
<input type="text" id="search" accesskey="s">
<button type="submit" accesskey="s">Submit</button>
```

### Unique `accesskey` values (correct)

Each element has a distinct `accesskey` value, so both shortcuts work as expected.

```html
<label for="search">Search</label>
<input type="text" id="search" accesskey="s">
<button type="submit" accesskey="b">Submit</button>
```

### Removing unnecessary access keys (also correct)

If the shortcuts are not needed, removing the `accesskey` attribute avoids the problem entirely and eliminates potential conflicts with browser or assistive technology shortcuts.

```html
<label for="search">Search</label>
<input type="text" id="search">
<button type="submit">Submit</button>
```
