-
Java Keyboard Shortcuts
I've been trying to find a way to use keyboard commands on my website and though I did find information I have had no luck in getting to work. I tried reading some java tutorials, but I've had no luck.
Here is my original code, plus the key i was trying to use with it.
<A HREF="C2.HTML"><IMG SRC="BACK.GIF" ALIGN="LEFT" TARGET="MAIN" ALT="BACK"> (Left Arrow)
<A HREF="02.HTML"><IMG SRC="NEXT.GIF" ALIGN="RIGHT" TARGET="MAIN" ALT="NEXT"> (Right Arrow)
<A HREF="INDEX.HTML"><IMG SRC="INDEX.GIF" ALIGN="CENTER" TARGET="MAIN" ALT="INDEX"> (Home)
Also i've been trying to find a way to create a keyboard shortcut (spacebar) that will allow me to toggle the side bar on my website.
Here is some information I found.
http://www.vbforums.com/showthread.p...=java+keyboard
http://www.vbforums.com/showthread.p...=java+keyboard
-
You want JavaScript, not Java.
Or CSS, there's a way to specify shortcuts with CSS.
-
Thanks, corn I'll see what i can find out about CSS.
-
Well I got this far
Code:
<SCRIPT LANGUAGE="JavaScript">
var key = new Array();
key['w'] = "index.html";
key['a'] = "c2.html";
key['d'] = "02.html";
function getKey(keyStroke) {
isNetscape=(document.layers);
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;
</script>
My question is that what would the key code for the spacebar and the arrow keys be, or is that because these keys are used in IE they are unavilable for JavaScript.
Also would it be possible to, instead of defining a link, direct it to a preexisting link in the html.
-
Arrow keys are available somehow, but I can't remember how.