Is there a reason why the following code should not return anything in my console log ?!
document.onkeypress = zx();
function zx(){
console.log(event.keyCode);
}
window.onkeypress also does not work.
Other attempts were made, for example:
document.onkeypress = zx(event);
function zx(event){
console.log(event.keyCode);
}
-
document.onkeypress = zx;
function zx(){
console.log(event.keyCode);
}
Thank!
source
share