Is there a way to detect 2 key presses at once?

Hi, I’ve mainly been working in p5.js, and some time ago, I was porting one of my javascript games to processing and I noticed there isn’t really and equivalent in processing. I’ve tried:

if (keyPressed) {
  switch key {
    case "a":
      // do thing
      break;
    case "b":
      // do other thing
      break;
  }
}

but this doesn’t work if both are pressed and I’ve also tried with if statements. Is there an equivalent to this in processing? I want the key detection to work for every frame similar to the keyIsDown() function in p5js. Thanks!

Hi @graph100,

You might want to look at those links (multiple keys is a known issue) :

Also note that some keyboards don’t support the same number of keystrokes at a time :

1 Like

https://www.reddit.com/r/processing/comments/bshqa8/how_would_i_make_a_keypressed_function_support/eor5epo/

1 Like