Google Answers Logo
View Question
 
Q: Hotkeys on my website ( No Answer,   5 Comments )
Question  
Subject: Hotkeys on my website
Category: Computers > Internet
Asked by: usefulcat-ga
List Price: $4.50
Posted: 05 Dec 2002 14:07 PST
Expires: 07 Dec 2002 08:09 PST
Question ID: 119942
I'm constructing a website for my dissertation and I wish to allow the
users to be able to navigate through it using hotkeys. For example:
CTRL-H takes them to the home page
CTRL-S submits a completed form
ALT-X allows them to log out

Something along these sorts of lines. The site will be using Perl
Scripts.
I know that the browsers have their own hot keys, for example Netscape
lets you navigate visited pages backwards and forwards with ALT-left
arrow and ALT-right arrow. I want to identify hot-keys specifically
for my site though, not generic ones coded into the browser.

Can this be done, and if so how?

Thanks for your help,
UsefulCat

Clarification of Question by usefulcat-ga on 06 Dec 2002 08:24 PST
Thanks Darthcow, this is a good start. I didn't realise there was such
a tag in HTML, many thanks!

I've tried your suggestion, and it works quite well:
http://www.usefulcat.com/hotkeys.html

This is along the lines of what I'm looking for but it has a couple of
problems.
1) Netscape doesn't support it - though the version I'm running isn't
the most recent, so I'll check this
2) More importantly the accesskey tag allows you to select the link,
but not actually execute it, so you have to press return.
(oh, and it only allows for ALT-? hotkeys as explained)

What I need is a method that does the same, but doesn't require the
user to press return, it just does it straight off.
I'm quite happy to implement it in javascript, perl or any other
scripting language to carry out the task.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Hotkeys on my website
From: darthcow-ga on 05 Dec 2002 20:52 PST
 
The easiest way is to add accesskey="h" on the link to your homepage,
accesskey="s" on the submit button for the form, accesskey="x" on the
link to logout. This will allow a user to type ALT+H to go to your
homepage, or whatever. Anything beyond that (e.g. using Ctrl instead
of Alt) will require some complex and annoying javascript. Just be
certain you aren't overwriting any default browser behaviors, or that
could be frustrating for your visiters.
Subject: Re: Hotkeys on my website
From: sun818-ga on 06 Dec 2002 15:40 PST
 
Take a look at Noah Grey's Greymatter news publishing script. He
utilizes the hotkeys for some of news administration functions.
Subject: Re: Hotkeys on my website
From: lot-ga on 06 Dec 2002 17:50 PST
 
accesskey is quite cool! Though doesn't work for Mac (if that's
important)
I was thinking something in javascript like 'keycompare' using the
ASCII keyboard number and if matches key in the script to execute an
action. Unfortunately I'm not a javascript expert, so it's only a bit
of a brainstorm.
regards lot-ga
Subject: Re: Hotkeys on my website
From: darthcow-ga on 06 Dec 2002 23:43 PST
 
Take a look at http://www.stephanhoyer.com/keycode.html

There I put up a page that I know works with IE 6, but probably for
any other recent (5+) IE browser as well. When you do a "keydown", it
reveals the number for the last key down. When you do a "keypress",
generally pressing a key with Ctrl, it reveals that as well. If you
look at the code (it's in JavaScript), you'll notice the
keyPressTrigers and keyPressActions array variables defined. These
variables allow you to define javascript actions for when a certain
key is pressed. Along with location.href as used in the example, you
can use 'formname.submit()' to submit a form and 'formname.reset()' to
reset a form. You'll want to copy all the code with the
<script></script> tags and remove the lines with innerHTML in them to
use the code on your site. I can't offer any guarentees, but it should
work if your visiters are using newer browsers (and probably windows
will be required too).
Subject: Re: Hotkeys on my website
From: lot-ga on 07 Dec 2002 04:30 PST
 
darthcow-ga's latest implementation works with Macs as well :-)
I found a solution that works with single key presses but thought it
might be an issue if people are entering data into a form (typing form
data would set off the hot key accidently and send users whizzing to a
different URL), but darthcow-ga's solution works with Control + key
combination too.
regards
lot-ga

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy