i want to create a simple event handler for a game, here's my code
$(document).keydown(function(e){
switch(e.keyCode){
case 65: //left (a)
console.log('left');
break;
case 68: //right (d)
console.log('right');
break;
}
});
the problem is that if i press and hold a key, after a little it triggers multiple times. how can i prevent this behaviour? i'm running my code on google chrome