Jump to content
xisto Community
leiaah

Keyboard Shortcut For Links In Html?

Recommended Posts

Is there a way to make use of the keyboard when togging html links? I'm doing a project and it would be nice if the user won't be too mouse-dependent. He will have the option of using the keyboard as well. I'm thinking if the user does a particular keypress (CTRL + LETTER maybe?) the link will be "clicked". This is probably a stupid question but if anyone knows a way it would be so fantastic! :huh: Thanks.

Share this post


Link to post
Share on other sites

Use the Tab key to set the focus on links without using the mouse. 'Tab order' can be by the default order in which they appear in the code or as determined by the page author re-arranging the Tab order with "Tabindex=".

<a href="blah.com" tabindex="3">Blah Page 3</a><a href="blah.com" tabindex="2">Blah Page 2</a><a href="blah.com" tabindex="1">Blah Page 1</a>
And then 'return' or 'Enter' to activate the link.

Share this post


Link to post
Share on other sites

If you don't mind using Javascript, there is also a way to make it so the user is directed toward a certain page when a certain button is clicked. You could set this up by a link and give the user the key commands. Javascriptkit.com or javascriptsource.com I think those two are the best ones. Look under navigation. Hope it helps.

Share this post


Link to post
Share on other sites

I think what you are looking for is called Access Keys. It seems to do exactly what you want, the user pushes Ctrl + Letter on the keyboard and it takes them to a certain link. Simply use this code:

<a href="http://forums.xisto.com/no_longer_exists/;

The letter you use for the access key is generally underlined in the text shown, like menus and toolbars in various programs. If you want any more on this try this article.

Share this post


Link to post
Share on other sites

I believe that accesskeys works differently through browsers, for example, in order to activate the link with the given accesskey you have to press:in firefox: alt + "key"in internet explorer: alt + "key" and next "enter" to go to the linkin opera: still dont know...

Share this post


Link to post
Share on other sites

I think what you are looking for is called Access Keys. It seems to do exactly what you want, the user pushes Ctrl + Letter on the keyboard and it takes them to a certain link. Simply use this code:

 

<a href="sample.com" accesskey="s"><u>S</u>ample.com</a>
The letter you use for the access key is generally underlined in the text shown, like menus and toolbars in various programs. If you want any more on this try this article.

 

Thanks rvalkass. It works except that you have to press enter after hitting CTRL + Access Key but it's okay. Thanks again. :huh:

Share this post


Link to post
Share on other sites

Thanks rvalkass. It works except that you have to press enter after hitting CTRL + Access Key but it's okay. Thanks again. :huh:

 

It's alt + access key actually and it's perfectly acceptable that someone should have to press two keys for site navigation, I mean, that's the way 99% of all program functions work when not using the mouse. About the only programs I can think of where pressing a single key produces a result is graphics programs when selecting different tools, so for most people, pressing a single key and suddenly being take to a different page would actually be unnatural and unexpected behaviour.

Share this post


Link to post
Share on other sites

Yes, i support Tyssens argument, although i could point to GMail as a site that uses only a single key navigation feature... (its turned on by default, so you must notice it and turn it on to make it work, so it can not be as 'unexpected' as a site which offers no warning).

As for a consistent and cross browser way to show a hint to users that they can navigate their site through the key board, I dont know if it exist, but would point to this ALA article that offers nice tips about accesskeys:

http://forums.xisto.com/no_longer_exists/

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.