PDA

Click to See Complete Forum and Search --> : Java Keyboard Shortcuts


Swatpup32
Nov 17th, 2003, 11:30 PM
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.php?threadid=265812&highlight=java+keyboard
http://www.vbforums.com/showthread.php?threadid=58833&highlight=java+keyboard

CornedBee
Nov 18th, 2003, 04:35 AM
You want JavaScript, not Java.

Or CSS, there's a way to specify shortcuts with CSS.

Swatpup32
Nov 18th, 2003, 11:45 AM
Thanks, corn I'll see what i can find out about CSS.

Swatpup32
Nov 18th, 2003, 02:36 PM
Well I got this far
<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.

CornedBee
Nov 19th, 2003, 02:00 AM
Arrow keys are available somehow, but I can't remember how.