accesskey (HTML attribute)
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>
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.
Value
This attribute takes as its value a single character, which can be numerical, alphabetical, or even a symbol.
Compatibility
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | Full |
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.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

