Log in

View Full Version : Looking for a script if you don't have a mouse



Dzsedzs
06-07-2010, 07:08 PM
Hi All !

I'm looking for a script with which I can command within my site special words with links (Menus) from the keyboard. An example of what I mean. For instance I don't have a mouse, but want to look around the website. There's the menu like 'Pictures', 'Contact', 'Sport', etc, and if I want to open one of them, just simply press for instance letter P on the keyboard (that refers to Pictures) and off I go to the Pictures area. This would be with Contact and Sports (pressing letter C and S). Just like in eg. Microsoft Internet Explorer pressing ALT F opens the File menu, just that I don't want to use ALT, only one letter, P for Pictures. An other example if you look at the top of this page as you are reading this forum, at the top you'll see" Home - User CP - FAQ ", etc. If you just press H it will do as you have just clikked on Home, U for User CP and F for FAQ.

I hope I was clear of what I mean. If not please let me know. Thx in advance.

Dzsedzs

djr33
06-07-2010, 09:57 PM
Most people have mice. If they don't, they can't use most websites anyway.

Also, the tab key on the keyboard is designed for this: it'll cycle through all elements. It may be slow, but it works.

Regardless, you just need to create an onkeydown event listener. Try google for that. I'm not sure of the exact code, but I've seen it done often.

I'm still not sure you need this, but it's possible. Be careful that you don't interfere with other expected functions on the page, though. For example, in firefox when I start typing I like it to search for text on the page. If it started opening menus instead, that would be odd.

bluewalrus
06-07-2010, 11:57 PM
Can try this, or using jquery and the keypress function some other way...

http://www.samburdge.co.uk/development/detecting-keypresses-cross-browser-using-jquery