accesskey attribute value must be unique
Rule Description
All accesskey
attribute values in a document must be unique. Put another way, accesskey
s must not be repeated to prevent unexpected effects for keyboard users.
Why it Matters
Specifying a accesskey
attribute value for some part of a document allows users to quickly activate or move the focus to a specific element by pressing the specified key (usually in combination with the alt
key). Duplicating accesskey
values creates unexpected effects that ultimately make the page less accessible.
For each defined accesskey
, ensure the value is unique and does not conflict with any default browser and screen reader shortcut keys.
Content is not operable by keyboard users with no or low vision who cannot use devices such as mice that require eye-hand coordination, users who have trouble tracking a pointer, or users who must use alternate keyboards or input devices acting as keyboard emulators.
How to Fix the Problem
Ensure all accesskey
values in the document are unique.
Look for and change duplicate accesskey
values.
Consider the following code:
<a href="google.com" accesskey="g">Link to Google</a>
<a href="github.com" accesskey="g">Link to GitHub</a>
change the value of one of the accesskey attributes to remove the duplicated value. An improved version of the above code looks like this:
<a href="google.com" accesskey="g">Link to Google</a>
<a href="github.com" accesskey="h">Link to GitHub</a>
Although the “providing access keys” option exists, we do not recommend including accesskey
attribute values due to limitations:
- Access keys are not supported by every browser.
- Access keys are not always obvious to the user.
- Access keys defined by the developer may conflict with default browser access keys.
- Using a letter from a label element as access key may cause problems when rendering content in multiple languages
The Algorithm (in simple terms)
Ensures that each element on the page with an accesskey
attribute has a unique value.