HI, currently I am using onkeydown on an input field, but I want to run the function when someone types no matter where on the page. I need to be able to pass the event keyword in the function
Well, you can associate the event funtcion to the <body> element. Example (works for Firefox and Explorer): <html> <head> <script type = "text/javascript"> function f_kd(ev) { var keynum; if (window.event) // IE { keynum = ev.keyCode; } else if (ev.which) // Netscape/Firefox/Opera { keynum = ev.which; } var keychar = String.fromCharCode(keynum); alert( "keynum='+" + keynum + ", keychar='" + keychar + "'" ); } </script> </head> <body onKeyDown="f_kd(event);"> Hello </body> </html> Code (markup):