Multiple keys in java
Hi,
Can anyone help me..
I want to know how is the best way to know about a key state in java, if it´s pressed or not.
(I´m a c++ programmer, java beginner).
like GetKeystate() in c++..
THANKS A LOT!
Attach a KeyListener to the component you want to listen to key events from (usually your Canvas or Window object which you're doing your drawing on). Use the events generated to set flags which you can read in your other (game loop) thread.
If you want something closer to GetKeyState(), then try using LWJGL which is generally closer to regular C++ framework style, and provides an easy isKeyDown() method.
If you want something closer to GetKeyState(), then try using LWJGL which is generally closer to regular C++ framework style, and provides an easy isKeyDown() method.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement