Java – how do I know if I press shift?
In my game, I hope to use the left and right shift keys for different functions In Java (or another language), is there a way to distinguish between the two?
The keyevent class has only VK_ Shift, which corresponds to the left and right movement keys Same as control, alt, enter, etc
My main concern is that someone may press two keys quickly with two fingers at the same time to gain an unfair advantage Should I worry
Solution
I found a java tutorial containing Java webstart samples and source code It looks like the winner is keyevent getKeyLocation()
> KeyEvent. KEY_ LOCATION_ STANDARD > KeyEvent. KEY_ LOCATION_ LEFT > KeyEvent. KEY_ LOCATION_ RIGHT > KeyEvent. KEY_ LOCATION_ NUMPAD > KeyEvent. KEY_ LOCATION_ UNKNowN
reference:
Key Listener Demo and Source Code