: : I'm working with a perl script where I want to poll the keyboard; I've found snippits for the handler itself, but what I'm in the need of is a way to clear the event without having an alert box or submit button. I had the right combination that worked with both IE and Firefox, but I saved over it - long story. :(
: :
: : Here's a basic sample of what I have now, but it doesn't work.
: :
: :
: : ...
: : <head>
: : <script...>
: : function handler(e) { <!--
: : the layer and document type of stuff
: :
: : document.write(keycode); // for output test
: : }
: :
: : function clearit(e) { <!--
: : return false;
: : }
: :
: : document.onkeydown = handler;
: : document.onkeyup = clearit;
: : //--></script>
: : </head>
: : ...
: :
: :
: : When it was *working,* I could press a key and get the code with each key press. I can't figure out what I did though to cancel the event.
: :
: : Any ideas on what needs to be done.
: :
: : TIA
: :
:
:
: First, for IE, you need to add the following into your handlers,
:
: if(!e) e = window.event
:
: Second, you want to use e.keyCode other than just keycode.
: e.g.
:
: function handler(e){
: if (!e) e = window.event;
: alert('You pressed ' + e.keyCode);
: }
:
I'd all but forgotten this topic. :O
I *think* what I did before was to write the code to a cookie, and then read it back for printing. The goal was to poll the keyboard (arrow keys in particular) for image swapping. I needed to cancel the event so that the swap was transparent to the user... it was for a game.