I am building a Java game in Swing, and I have an issue where keyPressed
events stop registering after holding the A or S keys for too long on Mac (this is a big problem considering that the game uses WASD movement).
After digging around Stack Overflow, I found out that holding down keys like this suspends focus because it attempts to open the accented characters menu, even though the normal list of accented characters does not appear. When I disable the character accents menu on my Mac, everything works fine. However, I'd like to know if there is a Java-native way to work around this behavior (such as a wrapper for KeyListeners
) since I don't want all Mac users to have to deal with this issue.