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


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‘) {
  } 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?