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

**URL:** <https://discourse.processing.org/t/keypressed-is-true-even-with-no-keys-actively-pressed-after-certain-inputs-in-p2d/42739>\
**Category:** Processing\
**Created:** [September 11, 2023, 4:15am UTC](https://discourse.processing.org/t/keypressed-is-true-even-with-no-keys-actively-pressed-after-certain-inputs-in-p2d/42739 "2023-09-11T04:15:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![User442B](https://avatars.discourse-cdn.com/v4/letter/u/db5fbb/32.png) [@User442B](https://discourse.processing.org/u/User442B)\
**Post date:** [September 11, 2023, 4:15am UTC](https://discourse.processing.org/t/keypressed-is-true-even-with-no-keys-actively-pressed-after-certain-inputs-in-p2d/42739/1 "2023-09-11T04:15:32Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [September 11, 2023, 10:24am UTC](https://discourse.processing.org/t/keypressed-is-true-even-with-no-keys-actively-pressed-after-certain-inputs-in-p2d/42739/2 "2023-09-11T10:24:51Z")

</div>

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.

> **[Issues · processing/processing4](https://github.com/processing/processing4/issues)**
>
> Processing 4.x releases for Java 17. Contribute to processing/processing4 development by creating an account on GitHub.

Cheers  
— mnse
