keyPressed is True even with no keys actively pressed after certain inputs in P2D

I have noticed an odd behavior when using P2D. The variable keyPressed is stuck on True after making a specific key combination with a letter and Shift or CTRL. If I do the following:

  1. Press and hold a letter key
  2. Press and hold Shift (while still holding letter)
  3. Release letter (while still holding Shift)
  4. Release Shift

keyPressed is now true with no keys pressed. Pressing the same letter key again seems to reset it. So if you did a+Shift, press and release a again to set keyPressed back to false. You can try to reproduce it with this sketch:

color black = color(36,39,45);
color green = color(141,187,110);
void setup(){
  size(1600,900,P2D); 
}

void draw(){
  if (keyPressed){
    background(green);
  } else{
    background(black);
  }
}

This does not happen with the default renderer. It’s an oddly specific combination, so I am not sure what’s going on here.

Hi @User442B,

I can also re-produce this with the default renderer by doing the steps slower, but not as constantly as on the P2D renderer.

You should report this issue on github issue page.

Cheers
— mnse

1 Like