You are here: irt.org | FAQ | JavaScript | Misc | Q402 [ previous next ]
It isn't possible to capture the cursor keys themselves. However, the following will capture the < and > keys in Netscape Navigator 4 and/or Internet Explorer 4:
<script language="JavaScript1.2"><!-- function netscapeKeyPress(e) { if (e.modifiers & Event.SHIFT_MASK) { if (e.which == 60) alert('< pressed'); if (e.which == 62) alert('> pressed'); } } function microsoftKeyPress() { if (window.event.shiftKey) { if (window.event.keyCode == 60) alert('< pressed'); if (window.event.keyCode == 62) alert('> pressed'); } } if (navigator.appName == 'Netscape') { window.captureEvents(Event.KEYPRESS); window.onKeyPress = netscapeKeyPress; } //--></script> </head> <body onKeyPress="microsoftKeyPress()"> </body>