Home › Forums › JavaScript › Javascript multiple keydown at once › Reply To: Javascript multiple keydown at once
January 2, 2018 at 2:53 pm
#264792
mpboom
Participant
It would be helpful if could post a bit more code, and in a better way.
However, something like this would work, I believe:
document.addEventListener("keypress", planeAction)
function planeAction() {
if (event.key = ‘KEY TO FIRE‘) {
//fire
} else if (event.key = ‘KEY TO MOVE LEFT’) {
//move left
... and so on
You seem to have two functions – do you also have two event listners?