62
rated 0 times
[
64]
[
2]
/ answers: 1 / hits: 51539
/ 13 Years ago, tue, may 24, 2011, 12:00:00
I'm using this code to check for keydown and display the string 'Pressed' while a key is down.
<body onKeyDown=doKey(window.event.keyCode) onKeyUp=doKey2(window.event.keyCode)>
<script>
function doKey($key) {
document.getElementById('keydown').innerHTML='Pressed';
}
function doKey2($key) {
document.getElementById('keydown').innerHTML='';
}
</script>
<div id=keydown></div>
The problem is that for some reason it's only working on Chrome. I think the 'window.event.keyCode' doesn't return anything. How do I make it work at least in Firefox too? Thanks
More From » javascript