accesskey (HTML attribute)

Spec
Depr. Version
No HTML 4
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2
Full Full Full Full None

Syntax

accesskey="key"

Description

The accesskey attribute allows the user to activate a control on a page using a keyboard shortcut. This may save time for users who would otherwise need to tab through a series of form controls or move the mouse to get to the desired link. The key combination that activates the link to which the accesskey is applied varies depending on the platform and browser combination. For IE/Windows, users press Alt + accesskey, while Firefox/Windows users press Alt + Shift + accesskey; users of most Mac browsers press Ctrl + accesskey; in Opera, pressing Shift + Esc displays a list of links for which accesskey attributes are defined, allowing users to choose the key they want to use.

Generally speaking, browsers do not provide any indication to users that an accesskey attribute is defined on the link, which is a big issue with the accesskey. Most commonly, the accesskey value is indicated within a title attribute, but this solution still relies on the user mousing over the element to which the accesskey is applied. As such, you may wish to state the accesskey value in some other way, for example:

<a href="cakes.html" accesskey="c">lovely range of cakes
    [access key = c]</a>

Admittedly, this may not be practical or cosmetically pleasing, but without this hint, the user may never realize that an accesskey is available.

Example

In this example, an accesskey has been defined on the link to the cake sales page:

<a href="cakes.html" accesskey="c">lovely range of cakes</a>

Value

This attribute takes as its value a single character, which can be numerical, alphabetical, or even a symbol.

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full None

There’s some variety in the way that the accesskey is activated, but it can work well. The downside of using this attribute is that the keystrokes you define may clash with those defined by other technologies such as screen readers or magnifiers. In addition, different language browsers use different accelerator keys for their own menu options, and these, too, may clash with the accesskeys you’ve defined. As such, accesskey may not work as expected for all users. It may, however, be very useful in controlled environments, such as intranets, where you know exactly which browsers and languages users are running.

User-contributed notes

There are no comments yet.

Related Products