This is a really weird issue, but I just have a simple keyListener added to a JPanel that prints on keyPressed and on keyReleased. Usually it works fine, but on certain keys
I ran into this issue recently, it is caused by the MacOS showing a context menu when you hold certain keys down (To allow you to chose alternative language characters) and the bug report page had a good solution that worked for me:
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8167263
To disabled the character accent menu and enable auto-repeat, type the following at the command prompt:
defaults write -g ApplePressAndHoldEnabled -bool false
This can be reversed with the following:
defaults write -g ApplePressAndHoldEnabled -bool true
I just tried this on the mac console and my java application no longer has the key problem.
More troublesome keys were reported here
https://community.oracle.com/thread/4115318
It seems at this moment the best workaround is to avoid the use of
z, c, n, a, s, e, y, u, i, o
I fixed it by going into my system preferences -> keyboard and moving the key repeat slider all the way to the left to "Off".
It appears that this is a Java bug that arose after people upgraded to MacOS Sierra:
Java Bug Database
Reddit post
As a temporary workaround you might try using keys other than the standard WASD for controlling movement.