Java – SWT: check whether multiple keys are pressed at the same time
•
Java
I want to develop a small game in Java and SWT
Thank Phineas in advance
Solution
In fact, you can achieve it Each key and key triggers its own event, so you can know exactly when the key is pressed and when it is pressed
Example: when the down arrow key event is triggered, you start moving the right click pedal to the right When the keystroke event of the X key is triggered, you begin to move the left keyboard down When the key up event of the X key is triggered, you will stop moving the left dial. When the key up event of the down arrow is triggered, you will stop moving the right dial. = > You can control them independently of each other
You can wrap all this in some kind of utility to make the solution clearer
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码