accesskey (HTML attribute)
Example
The accesskey
for this group of controls assigned to
"d":
<form> <label for="perfectday">Describe your perfect day:</label> <textarea id="perfectday" accesskey="d"></textarea> <input type="submit" value="Tell us" /> </form>
Description
The accesskey
attribute allows the user to quickly activate a control on a page using a
keyboard shortcut. This may present a time-saver for a user rather than
having to tab through a series of form controls to get to the desired link
or moving the mouse cursor. The key combination required to activate the
link that has the accesskey applied differs
depending on the platform/browser - for IE/Windows it is the ALT key +
accesskey, while for Firefox/Windows it’s ALT +
SHIFT keys + accesskey ; for most Mac browsers it’s
CTRL + accesskey; for Opera, it’s Shift + Esc,
which brings up a list of links that have accesskey
attributes defined, then you hit the key that you need from that list to
activate.
Generally speaking, browsers do
not provide any hint that the form control has an
accesskey attribute defined - lack of
discoverability is a big mark against the
accesskey. The most common method for indicating
the accesskey value is within a title
attribute. However, this is still reliant on the user hovering over the
element it is applied to with their mouse, so you may wish to state the
accesskey value in some other way, for example:
<form> <label for="perfectday">Describe your perfect day [access key = d]:</label> <textarea id="perfectday" accesskey="d"></textarea> <input type="submit" value="Tell us" /> </form>
Admittedly, this may not be practical
or cosmetically pleasing, but without this hint, the user may never find
out that there is an accesskey available … in which
case you may as well not have bothered in the first place!
Value
A single character, can be numerical, alphabetical or even a symbol.
Compatibility
| IE | 5.5 | None |
|---|---|---|
| 6.0 | None | |
| 7.0 | None | |
| Firefox | 1.0 | None |
| 1.5 | None | |
| 2.0 | None | |
| Safari | 1.3 | None |
| 2.0 | None | |
| 3.0 | None | |
| Opera | 9.2 | None |
| 9.5 | None |
Some variety in the way that the
accesskey is activated. The biggest problem with
this attribute is that keystrokes defined may clash with other
technologies. For example, a user may have assistive technology (a screen
reader or screen magnifier) which may share keystrokes with those that
you’ve defined in the accesskey attribute. In
addition, different language browsers use different ‘accelerator keys’ for
their own menu options which may also clash. Because of this, the
accesskey may not work as expected for all users
and as such many web standards advocates strongly recommend against using
it at all. It may, however, have its place for controlled environments,
such as Intranets or for point-of-sale environments, such as a cashier’s
terminal, where you know exactly what browsers and what languages the
users are running. In this instance, using a standard set of
accesskey attributes may be of great benefit.
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.

