If the user holds down the key, multiple keydown events are fired. For usability reasons I need to use keydown, not keyup, but I want to avoid this situation. My relevant co
(Copied from another question which turned out to be a duplicate of this one.)
dmaurolizer's KeyPress library gives fine control over all keyboard events. You provide callback functions for events. The keydown event sends an optional isRepeat param so you can ignore auto-repeats. Here's a sample using that functionality for the thrust control in a video game:
var my_combos = listener.register_many([
{
"keys" : "up",
"on_keydown" : function(e, num, isRepeat) {
if (isRepeat) return ;
thrust = 0.1;
},
"on_keyup" : function() {
thrust = 0;
}
}
]);