Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

Multiple Access Keys

2:56 pm on Feb 28, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 5, 2007
votes: 0


I'm trying to develop my website for mobile view such as cell phones.

Right now my page displays nine links to different article, each with an accesskey attribute using keys 1-9, to enable people to select a link with thier phone's buttons.

<a href="/foo/" accesskey="4">Foo</a>

I am trying to add a feature to allow people to press 0 to read a random article.

I'm using PHP on my backend to accomplish this, my only problem is trying to have one link with multiple accesskeys and remain valid.

Would it be like:

<a href="/foo/" accesskey="0" accesskey="4">Foo</a>


<a href="/foo/" accesskey="0 4">Foo</a>


<a href="/foo/" accesskey="0,4">Foo</a>

What I want to avoid is cluttering up my page by using:

<a href="/foo/" accesskey="0">Foo</a><a href="/foo/" accesskey="4">Foo</a>

Even though I might be able to use CSS to hide the second link (if CSS is even supported), I don't want to add to the file size.

Any help would be much apprciated.

4:09 pm on Feb 28, 2008 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
votes: 12

According to the HTML spec:

The accesskey attribute takes single character data:

This would imply that you can't assign multiple characters for a single accesskey.

However, could you perhaps do something like this:
<a href="/a1/" accesskey="1">Article 1</a>
<a href="/a2/" accesskey="2">Article 2</a>
<a href="/a3/" accesskey="3">Article 3</a>
<a href="/a8/" accesskey="8">Article 8</a>
<a href="/a9/" accesskey="9">Article 9</a>
<a href="/a2/" accesskey="0">Random</a>

In other words, you show a link for Random, and use PHP to assign the href to one of the existing links. This way, the Random functionality is obvious to your users, and you don't need to replicate the link text.

4:10 pm on Feb 28, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member penders is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:July 3, 2006
posts: 3123
votes: 0

As far as I'm aware you can't have more than 1 accesskey specified for any 1 element?! I'm not sure why you would need to?

Just trying to understand... Key 0 reads your random article, whatever that might be (possibly 'Foo'). And key 4 reads your 'Foo' article, the link for which still exists on your page. So both 0 and 4 will read the 'Foo' article, if 'Foo' is your random article. Is that right?