Note: This page is no longer maintained. I'll write a page about cross-browser event capturing as soon as I understand how it works.
In the Version 4 browsers, you can detect whether the user presses a key. The script runs in this page. Press a key, you'll see it appear in the input field below. If you see nothing, the key you pressed cannot be detected.
One major drawback: Arrow keys can only be detected by a Mac, not by a PC. Nonetheless, you can do nice things with this script.
You'll need to put the following script in the <HEAD>:
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- var scape = (navigator.appName.indexOf("tscape") !=-1) ? true : false; if (scape) document.captureEvents(Event.KEYPRESS); document.onkeypress = doKey function doKey(keyed) { input = (scape) ? keyed.which : event.keyCode; letter = String.fromCharCode(input); } // --> </SCRIPT>
Unfortunately, I can't explain this script. I just copied it and it works. A keypress is detected and the key ends up in the variable letter.