Is there any way to detect a key being pressed in the window? I have tried the following but it doesnt work:
document.onkeyup = KeyCheck;
function KeyCheck()
{
var keyID = event.keyCode;
alert(keyID )
}
Printable View
Is there any way to detect a key being pressed in the window? I have tried the following but it doesnt work:
document.onkeyup = KeyCheck;
function KeyCheck()
{
var keyID = event.keyCode;
alert(keyID )
}
I know this is silly but could you need a semi colon after alert(...);
If you look in the bottom right of the browser you might see an error.
// You may need a doctype (or use document.body) for ie.
// For non-ie you need the argument that is passed in non ie event handlers
Code:document.onkeyup= function(e){
e= window.event || e;
alert(e.keyCode);
}
Thanks mrhoo that does exactly what i need :)