In my index.html I have this code.
I would need to add onkeydown
event to that body in Main.onLoad().
Any idea how to do it?
<body id="body"
onload="Main.onLoad();"
onunload="Main.unload();"
onmousedown="Main.mouseDown();"
>
<body id="body"
onload="Main.onLoad();"
onkeydown="TVA.keyDown(event);"
onunload="Main.unload();"
onmousedown="Main.mouseDown();"
>
In a Javascript block, try to use window.onkeydown
(MDN).
You can also use document.onkeydown
and document.body.onkeydown
.
Here is an example for you:
document.body.onkeydown = function(e){
alert(String.fromCharCode(e.keyCode)+" --> "+e.keyCode);
};
The code above can be put in any valid JavaScript block (such as Main.onLoad()
function).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With