keyPressed() events get missed when another key is held

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. :smiley:

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

2 Likes