The following code works for capturing key presses on IE, Netscape, Opera 7,and somewhat with Opera 6.
HTML Code:
<html> <script language="JavaScript"> function keyHandler(e) { var pressedKey; if (document.all) { e = window.event; } if (document.layers) { pressedKey = e.which; } if (document.all) { pressedKey = e.keyCode; } pressedCharacter = String.fromCharCode(pressedKey); alert(' Character = ' + pressedCharacter + ' [Decimal value = ' + pressedKey + ']'); } document.onkeypress = keyHandler; </script> <body>Press any key.



