jump to content
site map
search this site
 

Internal Accesskeys

11th Oct 2006

It's probably not a new concept nor is it rocket science but it's helluva useful and I haven't seen it anywhere else. And in the light of the recent flurry of blog posts questioning what web accessibility actually is it puts things in a clearer light, from my own perspective anyway. I'm talking about Accesskeys. Not the plain old hyperlink Accesskeys you are probably aware of but Internal Accesskeys.

This isn't a diatribe about defining what accessibility is or isn't. From my viewpoint there's a vast grey area stretching between Accessibility and Usability; two seperate subjects in almost any other area of daily life but on the web (and when it comes to designing websites that work) they share a lot of common ground. Having a 'usable' site should be the main aim of any professional web designer. And what better way is there to make your site more usable than letting your visitors set their own Accesskeys?

It's easy to provide this functionality because Dan Champion has already produced a simple to use and highly effective PHP script that you can implement into the accessibility page on your site. Gez Lemon produced a similar script in ASP. I've been using Dan's script for a while now and it occured to me that the handiest shortcut keys are missing from all the implementations I've made so far: back to top and jump to content.

It's simple to update Dan's script to include these extra internal links. If you check out Dan's script you'll find a multi dimensional PHP Array declared near the top called $accesskeypages; this array lists all the pages you want to provide an accesskey for. Below is an example of how I've updated this array in a recent site (The Bard Game) with my additions in bold:

$accesskeypages = array(
"index.php" => array("token" => "home", "default" => "", "label" => "home"),
"sitemap.php" => array("token" => "sitemap", "default" => "", "label" => "site map"),
"contact.php" => array("token" => "contact", "default" => "", "label" => "contact us"),
$_SERVER['PHP_SELF']."#content" => array("token" => "jumpto", "default" => "", "label" => "jump to content"),
$_SERVER['PHP_SELF']."#top" => array("token" => "top", "default" => "", "label" => "top of page"),

);

This takes the current page and appends an internal link.

And, because I usually sit with my left hand on the keyboard (Alt+Tab between pages all the time), I find that setting 'jump to content' as Alt+z and 'back to top' as Alt+a work well. Also, once or twice I had problems getting Dan's script to work. The reason was down to a conflict in setting cookies. The solution was to include the Accesskeys script before any other scripts.

I hope you find this useful.

Retweet This

Category: accessibility
Technorati tags:
Add to del.icio.us

  1. Mike Cherim said...

    Good idea Blair as those are two very important links in my opinion. I wonder, though, is it really necessary to add the $_SERVER['PHP_SELF']. part of it? If you're pointing to a fragment identifier, and you'll be using a link provided on any given page, it should just work without that should it not? As long as the ID or fragment is the same of every page. Or am I missing some cruical point? Not that me missing something would surprise me ;-)

    Wednesday 11th October 2006 11.29pm

  2. Dan said...

    That's a really nice use for accesskeys, good job. Mike's right about the PHP_SELF being superfluous, so long as your internal links are relative and only consist of the fragment identifier, which in almost all cases they will.

    Alt-z is good for me too, though I'm a Ctrl-home man for getting to the top of anything. ;-)

    Thursday 12th October 2006 12.38pm

Comments are now closed

This was posted on 11th Oct 2006.

The best of The Letter

5 things you did not know about Blair Millen

I was named after SantaI lived a recklessly wild and dangerous life for a while (for fun)I used to paint living rooms for a livingI did a milk round w [...]

7 comments

Vicious Loop

Snotters, crusty nostrils, tickly throat, irritating cough, big wet sneezes and mild fatigue; and that's before I even venture out the front door in t [...]

comments



Subscribe

Subscribe to The Letter by email (opens a new window)

Enter your email address

Delivered by FeedBurner

Twitter

You should follow me on Twitter