Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase

How to Add Hotkeys to your HTML Pages

Keywords: 	 hotkeys html

Ever want to add hotkeys to your web site? While this may sound like a silly question at first, it can really increase the efficiency of your web site if you add hotkeys to popular pages.

To try it out, hit the following keys that correspond to their sections. To get back, just hit backspace or the back button in your browser.

a - Artist
d - Designer
p - Programmer
w - Webmaster
If all went well, when you hit those keys your browser should have went to the corresponding part of the web site.

To try this out on your web site, just copy this JavaScript below into your page, preferably between the tag. After that, just change the keys between the brackets and the URLs between the quotes. If you want more than four, just copy and paste another line in. You can add virtually as many as you want.

var key = new Array();
key['a'] = "../../artist/index.html";
key['d'] = "../../designer/index.html";
key['p'] = "../index.html";
key['w'] = "../../webmaster/index.html";

function getKey(keyStroke) {
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
for (var i in key) if (which == i) window.location = key[i];
document.onkeypress = getKey;
// -->
Don't forget about adding a list of the hotkeys somewhere so that people know which ones to use. You can even add an underline to the letter in the text linking to the sections so that people will know which key to hit, for example: Artist.
Article ID:   W14529
Filename:   Adding HotKeys to HTML Pages.txt