Sign in to follow this  

Multiple keys in java

This topic is 4543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 4543 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this