Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Javascript multiple keydown at once Reply To: Javascript multiple keydown at once

#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?