The use of "access keys", a guide for webmasters

August 10, 2006 | Published in: Accessibility, Standards & SEO | Tags: , , 4

Help keyAccess Keys have been around since HTML 4.0, and have many accessibility benefits, they are also part of the WCAG accessibility guidelines. However despite this they are uncommon, and fairly unknown; few
webmasters choose to incorporate them in their websites.

This article attempts to describe what access keys are, their benefits and implications, and practical uses of them in your web sites. Using access keys is easier than you may of thought!


What is an access key?

An access key is a HTML attribute that allows users to navigate to a certain link via the keyboard, rather than clicking. Its primary goal is to increase accessibility and usability in web pages for users who find using a mouse difficult.

Accessibility benefits

Access keys mainly benefit users with motor difficulties (users who find moving difficult, and have difficulty with pointing devices such as mice). By providing navigation with access keys, users have the option to perform a simple keystroke to navigate links.

On a PC, access keys are normally used by holding ‘alt’ and pressing the access key.

On a MAC, access keys are normally used by holding ‘ctrl’ and pressing the access key.

WCAG

Providing access keys is part of the WCAG priority 3 guidelines (here), in which it states that important links should have a keyboard shortcut.

Provide keyboard shortcuts to important links (including those in client-side image maps), form controls, and groups of form controls.

[Priority 3] (Checkpoint 9.5)

The WCAG also provides more detail on this checkpoint:

Keyboard access to active elements of a page is important for many users who cannot use a pointing device. User agents may include features that allow users to bind keyboard strokes to certain actions.

Priority 3 checkpoints are not essential, but will aid your visitors, so are worth an attempt.

Coding the access keys

Here is the bit most of you will want to read, the access key code!

When using access keys in links, the ‘accesskey’ attribute goes inside the tag.

<a accesskey="key">Link</a>

Replace key with the key you wish to set up as the access key. *Please note, this could interfere with the browsers shortcut keys (see browser implications below).

So that’s the code, if you’ve successfully made an access key give yourself a pat on the back.

Practical uses in navigation

So how can we use these access keys in our navigation to aid users? Here is a simplified version of Blue Anvil’s navigation, note the use of access keys in the links.

<ul><!-- list items -->
	<li><a accesskey="1" href="index.php">Journal </a></li>
	<li><a accesskey="2" href="/services">Services</a></li>
	<li><a accesskey="3" href="/tag/portfolio">Portfolio</a></li>
	<li><a accesskey="4" href="/about">About</a></li>
	<li><a accesskey="5" href="/contact">Contact</a></li>
</ul>

So now (in windows) the user can press alt and the access key to navigate to my main sections:

  1. Journal
  2. Services
  3. Portfolio
  4. About
  5. Contact

Sites that use access keys – some examples

Larger sites usually do sometimes use access keys, the best example I could find being the BBC:

www.bbc.co.uk – very accessible, uses the following:

  1. go to Access Keys documentation page
  2. go to bbc.co.uk Home page
  3. skip to main content of current page (for non-visual browsers)
  4. go to bbc.co.uk Site Map page
  5. go to bbc.co.uk Search box

Simple, yet effective. But now we need a way of showing the user that the access keys exist, read on.

Making access keys known to the user

Provide suitable documentation

Provide the user with a quick guide to the accessibility features of your site, this is just so the user can find out, and be aware, about features you have implemented. You can see my help guide by looking at the very top of the page, ‘help & accessibility’.

Labelling

Simple labelling can tell the user your access keys and will help them identify that your site features them.

If you are using letter access keys you could underline the access key letter.

If you are labelling with numbers you could give it a different style/look or underline it also.

To do this, the most ‘browser safe’ way would be to use simple spans and css. Lets look at my earlier blue anvil code, but first add a numeric label to show the access key (like you see on the site already).

<li><a accesskey="1" href="index.php">1 Journal </a></li>

Now my ‘journal’ link is shown as being ‘1′. Now lets add a span and style the link.

<li><a accesskey="1" href="index.php"><span class="key">1</span> Journal</a></li>

Now the access key is surrounded by a span, with a class of key, we can apply style in the css file. Lets add a style to underline it. This code goes in the stylesheet:

.key {   text-decoration:underline;  }

And that would be it, access keys would be displayed as underlined. *Extra: for you fussy people who don’t like spans (Anthony), you can use the em tag.

<li><a accesskey="1" href="index.php"><em>1 Journal</em></a></li>
a em{   text-decoration:underline;  }

If you are feeling adventurous you could use css 2 pseudo elements for the first letter which keeps content and style separate, however I find this way less appealing. See ‘a list apart’ article on access keys for more information on using pseudo classes (ALA – Unlocking hidden navigation).

Labelling sensibly

Obviously, the label you use will affect usability. What would be the point in having the ‘home’ link as access key z? Use a relevant key. So for ‘home’ the best letter would be ‘h’ (of course you could still use a number like me).
Also if you were using numbers, on for instance a navigation bar, don’t jumble the order of access keys, keep them in numeric order and keep it simple. e.g. 2 home 5 services = bad, 1 home 2 services = good.

Browser implications

Despite being around a long time, their are still issues related to access keys, especially in older browsers.

Browser support

Access keys are supported by:

  • IE 4+ (PC)
  • IE 5+ (MAC)
  • Firefox (pc and mac)
  • Netscape 7+
  • Safari/omni web (MAC)
  • Opera (version 7+ ?)

Alternative access key execution keys

Different browsers have different ways of executing access keys, the main browsers are outlined below:

  • IE (PC, including IE 7) – Hold alt, press access key, release, press enter.
  • IE, safari (MAC) – Hold ctrl, press access key
  • Firefox, Netscape – Hold alt, press access key.
  • Opera – Hold shift, press escape, release, press access key.

Shortcut key interference

Access keys can sometimes interfere with other programs that use the same key, or the browsers own shortcuts.

This includes certain screen reader software (e.g WindowEyes).

Because of these limitations, I tend to only use numeric access keys, as application shortcuts dont use them as much.

List Apart states:

Windows users will find that accesskeys take precedence over application commands, which can still be accessed from the keyboard by first typing the menu shortcut key (usually ALT) followed by the letter corresponding to the desired menu item.

ALA – Unlocking hidden navigation

So just to be sure, test your access keys in the main browsers before going live, just to make sure they don’t appear to be interfering with anything.

Other uses of access keys

This article has focused on access keys for links, but this is by no means their only use!

The over main usage is with forms/fields.

They can be applied to:

  • Buttons
  • Inputs
  • Labels
  • Legends
  • Text Areas

Code example

An access key in a label:

<label for="field" accesskey="f">Label</label>

Now by pressing (in windows, firefox) alt and f, the users cursor will jump to the text field the label points too, and they can add their input. This makes using forms a lot more accessible, just make sure the user is aware of this feature.

Lastly, access keys can be used in the ‘area’ tag (used for image maps) to provide keys for links within the element.

Closing statement

So there you have it, a quick guide to access keys, I hope it was useful, and I hope they help your users if you implement them.

Thanks for reading, please leave a comment!

Found this post useful? Why not buy me a coffee!

Related Entries

Popular Entries

4 Responses to “The use of "access keys", a guide for webmasters”

RSS feed for comments on this post.

  • 1 - Anthony says: Reply to this comment

    Gravatar

    Good article – Access Keys seem to be slowly taking off and I wonder if and how they will be implemented in the revision of WCAG.

    Comment made on February 9, 2007 at 5:41 pm

  • 2 - Mike Cherim says: Reply to this comment

    Gravatar

    While I love the idea of accesskeys, I recommend they not be used at all unless a script is provided like we did at Accessites.org allowing users to set their own. We used to use numbers 0-5 thinking they were safe choices (letters are trouble) but we learned differently. One day a fellow was using our contact form and had a chanracter in his name that required he type a character entity so he used Alt+0 to make that so. Next thing he knew he was on another page. Fortunately for us he reported it. That’s when we added the script.

    Comment made on February 9, 2007 at 5:42 pm

  • 3 - Mike J says: Reply to this comment

    Gravatar

    Hmm interesting, I’d never even considered the inpact on character entitys.
    But the script idea is good, just a bit of php and a cookie I take it?
    Thanks for that.

    Comment made on February 9, 2007 at 5:43 pm

  • 4 - Tom says: Reply to this comment

    Gravatar

    Very good article, I agree with Mike Cherim about the script.

    Comment made on February 9, 2007 at 5:44 pm

About this site

Blue Anvil is the online web design journal & portfolio of , a web designer from Norfolk, England. Read More »
ThemeSlice
  • Featured work - More

    • Beefjack
    • Integrity
    • theotaku.com
    • Manic Melon
  • Latest Tweet - More

    • Dropped yoghurt all down my pyjamas. Bugger. Working in my boxers. Ill get dressed some time. Soon.
  • Out of the blue - More

    • Wordpress 2.8 Memory Usage

      With the release of wordpress 2.8 some people are experiencing out of memory php errors along the lines of:

      Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 228968 bytes)

      You may also be seeing pages fail to load fully (for example the wordpress admin dashboard) if php error messages are hidden. I’ve already had one case where we thought certain plugins were to blame but in fact it was just out of memory. A possible fix (which worked in the previously mentioned case) is to add:

      @ini_set('memory_limit','64M');

      to your wp-config file. Has anyone else encoutered this error?

    • jQuery Curvy Corners 1.x and 2.x updated and moved to Google Code

      I have updated the jQuery Curvy Corners plugins (both versions) with jQuery 1.3.2 support and other enhancements. The beta 2 version is looking good and is working in all version of IE, Opera, and Firefox (as far as I can tell).

      You can grab the latest files from Google Code here. Enjoy.

    • I’m too nice: Wordpress Download Monitor plugin page add-on now included with Download Monitor version 3.1.

      It was going to be a paid add-on, but today I had a change of heart and bundled it with the newest version of download monitor. The add-on lets you make a download page using a shortcode; it lists your downloads/categories with full sorting, pagination, and search functionality. Not bad eh? See the documentation topic to see full instructions for usage, or see my download page to see it in action.

      And if you use it, please consider making a donation to ensure the continued development of the plugin!

    • 2 Announcements: New Support forum, and feedback wanted for new download page add-on

      First, I’ve implemented a support forum to Blue Anvil mainly for plugin support and ideas which can be found here. Hopefully this will make supporting my plugins easier. Feel free to add to the discussions (there is also a general web design forum too).

      Secondly, I’ve added a demo of the new download page add-on I’m making for Download Monitor. This will be a paid add-on and it would be cool to get any feedback or suggestions from anyone who would like such a feature. My download page is here. Please leave feedback on the forum or in the comments.