Jump to content
  • Advertisement
Sign in to follow this  
googa

Multiple keys in java

This topic is 4827 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
Advertisement
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
Thanks Orangytang, by the way do you know how can i access the main class from inside another one?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!