SWT: checking multiple keys simultaneously

I want to create a little game in java and swt. For this reason, I have to respond to KeyEvents. How can I check, for example, the up and q keys are compressed together?

Thanks in advance Phineas

+3
source share
4 answers

Actually, you can implement this. Each key down and the key has its own event, so you know exactly which keys are pressed, when and which keys are reset at any time.

: , . X, . Key key key, , , . = > .

- , .

+2

SWT ( , shift, alt ..). , , - "q" . , ( KeyEvent) , (50 ? ).

q , , , q , , , q. , . , q .

+5

Thank you for your responses! I just thought that I could develop the game with a little pon rather quickly, but I did not know that key bindings are so difficult to handle! The main obstacle is that the two oars must be moved independently (currently pressing keys interferes with the movement of opponents and vice versa).

0
source

Source: https://habr.com/ru/post/1763848/


All Articles