as indicated in other answers, there is no “onkeyfirstdown" or similar event to listen to.
the best solution is to keep track of which keys are already in the js object:
var keysdown = {}; element.addEventListener('keydown', function(evt) { if(!(evt.key in keysdown)) { keysdown[evt.key] = true;
thus, you will not miss keyfirstpressed events if more than one key is held.
(many other solutions posted here will only work when other keys are not omitted).
josh
source share