I have a doubt and I can't find this info. To manage keyboard inputs in games, I listen to keydown and keyup events with addEventListener() to update the state of a keyboard object, so in the game loop I can read if a key is down or not. Of course I want it to run between the game loops, but does it ? Or does it run at the very moment the key is pressed or released no matter if the game loop is running ?
document.body.addEventListener( "keydown", function(){/*function that updates my keyboard object*/} , true);
document.body.addEventListener( "keyup", function(){/*function that updates my keyboard object*/} , true);
function game_loop()
{ requestAnimationFrame(game_loop); }
game_loop();