I am trying to create a simple javascript game and I am fixated on how to handle keys.
A small example:
function keyUpEvent(event) {
alert(event.keyCode);
}
window.addEventListener("keyup", keyUpEvent, false);
I am running Ubuntu 9.10 and testing it in Firefox 3.5 and Chromium.
If I press and release the button instantly, I get a warning that should be expected, but when I press and hold the button, I get a short pause and then a series of warning windows, the expected result is that I only get a warning window when I remove the finger from the button.
I think this is because when I press and hold the button in the text area, for example, I get one character, a short pause, and then a series of characters: ddddddddddddddddd.
I believe that you can get around this or do it more correctly or anything, starting with this game, for example: http://bohuco.net/testing/gamequery/pong.html the seams should not be affected by this. But I notice that if I try jquery keyup demo (api.jquery.com/keyup/), I get the same problem.
How can I implement basic game key event processing?
Binni source
share