Fix keyPressed for multiple keys#5050
Conversation
Java2D and FX2D send multiple PRESSED and only one RELEASE event (at least on Windows). Therefore we have to keep track of what is pressed and what not. Most keyboards do not support pressing more than ~10 keys simultaneously, so this should not cause any performance problems. Fixes processing#5049
|
Perhaps a HashSet<Long> would be a better fit than an ArrayList<Long> for field pressedKeys here: Using a Set instead, statement Due to its hashable searching nature, a Set should be more performant when using methods such as contains(Object) & remove(Object) than a List. |
|
On the other hand, if the # of elements in the container pressedKeys is always small, I guess a List might be indeed faster than a Set in this case. O_o |
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Java2D and FX2D send multiple PRESSED and only one RELEASE event (at
least on Windows). Therefore we have to keep track of what is pressed
and what not. Most keyboards do not support pressing more than ~10 keys
simultaneously, so this should not cause any performance problems.
See focusLost() for possible problem when user overrides it and does not call super. It's there only to clear keys when ALT+TAB is pressed so the chance somebody will hit this is low.
Fixes #5049