April 16, 2012
document.onkeypress not working
Question by Saturnix
Is there any reason the following code should not return anything in my console log?!
document.onkeypress = zx();
function zx(){
console.log(event.keyCode);
} // zx
window.onkeypress
also doesn’t work.
Other attempts has been made, like these:
document.onkeypress = zx(event);
function zx(event){
console.log(event.keyCode);
} // zx
–
document.onkeypress = zx;
function zx(){
console.log(event.keyCode);
} // zx
Thanks!