# Accesskeys

> Each accesskey value must be unique. Duplicate shortcut keys can activate the wrong control or do nothing, confusing keyboard and screen reader users.

Source: https://knowledge.evinced.com/web/web-validations/accesskeys

The `accesskey` attribute values should be unique.

The `accesskey` attribute tells browsers and assistive technology to create keyboard shortcuts that move focus to, or activate, interactive elements. When two elements share the same value, keystrokes can trigger the wrong control or do nothing at all. Duplicate shortcuts can confuse keyboard and screen reader users and slow down navigation. Because support is inconsistent, use `accesskey` only when strictly necessary and always ensure each value is distinct.

## Pass Patterns

### Each access key is unique

```html
<a href="https://example.com" accesskey="g">Go to Example</a>
<button accesskey="s">Save</button>
```

## Fail Patterns

### Two elements reuse the same access key

```html
<a href="https://example.com" accesskey="g">Go to Example</a>
<button accesskey="g">Save</button>
```

## Try It Yourself

### Using a keyboard

1.  In your browser, press the access-key modifier, for example, *Alt* (Chrome, Edge, Safari, Opera) or *Alt + Shift* (Firefox) on Windows, *Ctrl + Option* on macOS, plus the assigned character key.
2.  Observe which element receives focus or is activated.

**Expected results:** Focus moves to, or the browser activates, the element whose unique `accesskey` attribute you pressed.

**Actual results:** If duplicate values exist, the shortcut may select the wrong element or fail entirely.

## FAQ

**Why is this rule considered a best practice?**

HTML permits duplicate `accesskey` attribute values, but doing so degrades keyboard and screen reader usability. Ensuring uniqueness prevents focus conflicts and aligns with widely accepted accessibility guidance, even though no single WCAG success criterion directly addresses it.

**Why is this issue marked as Serious?**

Conflicting shortcuts stop some people with disabilities from operating the interface efficiently, especially those who rely on the keyboard. The problem is reproducible in mainstream browsers and assistive technologies, and can block essential tasks.

## Standards and Regulations

This issue is classified as "**Best Practice**," meaning it isn't tied to a specific WCAG success criterion or any other regulation or standard; however it still affects the experience of some users. These issues fall outside formal compliance requirements, yet addressing them improves usability and accessibility in practice.

## Personas impacted by this issue

-   [Keyboard](https://knowledge.evinced.com/a11y-essentials/personas#keyboard)
-   [Screen Reader](https://knowledge.evinced.com/a11y-essentials/personas#screen-reader)
