# keyPressed() events get missed when another key is held

**URL:** <https://discourse.processing.org/t/keypressed-events-get-missed-when-another-key-is-held/12696>\
**Category:** Processing\
**Created:** [July 13, 2019, 6:33am UTC](https://discourse.processing.org/t/keypressed-events-get-missed-when-another-key-is-held/12696 "2019-07-13T06:33:49Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)\
**Post date:** [July 15, 2019, 2:24am UTC](https://discourse.processing.org/t/keypressed-events-get-missed-when-another-key-is-held/12696/18 "2019-07-15T02:24:51Z")

</div>

I’m uncovering more right now - the problem seems to be related to key repeat delay/rate i.e. the function of the OS where holding a key for long enough it starts repeating the `keyPressed()` event.

If I disable key repeating (with terminal command `xset r off`) the problem goes away instantly and I can’t reproduce the issue.

However, if I set repeat delay to 0 (i.e. so that it starts repeating the key instantly as soon as I start holding it, making it impossible to type) and repeat rate to 255 (maximum possible, 255 characters per second) (both with command `xset r rate 0 255`), the `keyPressed()` event of the second key misses almost always.

From that I guess that it misses `keyPressed()` event of a key only if another key is pressed at the same time due to being repeat-pressed by the OS.

I guess this can be explained by P2D/P3D dropping repeated `keyPressed()` events too sparingly, and by dropping such event at the same time another key is pressed, it drops the `keyPressed()` event for that key instead, and results in missing it. That is reinforced with JAVA2D renderer not dropping repeated `keyPressed()` events _and_ not having this issue.

**I believe that this is a bug in Processing’s P2D/P3D engine’s key processing code, specifically the one responsible for dropping repeated key events.**

I guess I’m the one who points it out after so much time is because my preferred key repeat delay/rate are a bit too extreme compared to normal user’s _(`xset r rate 170 60`, i.e. 170ms delay and 60 presses per second - coincides with P2D’s 60 frames per second therefore I’m having the issue?)_

I think I’m ready to go write a smart sounding GitHub issue for it to be fixed now, but I’ll wait for anyone to come maybe say something smart beforehand. 😃

Edit: no one said anything smart in 23 days, so I’ve posted an issue about this on GitHub: [https://github.com/processing/processing/issues/5904](https://github.com/processing/processing/issues/5904)

---

_[View the full topic](https://discourse.processing.org/t/keypressed-events-get-missed-when-another-key-is-held/12696)._
