Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

chrisrs

Keyboard Inputs

This topic is 5348 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

Can anyone suggest a method to gain keyboard inputs from multiple keys fast. The only method i have seen is switch/case statements which is only allowing 1 key at a time and to me seems a very poor method of input. Any help is appreciated! Thanks Chris

Share this post


Link to post
Share on other sites
Advertisement
the way i''ve seen it done (aka Half-life) is to grab a varible which the bits set on or off depending on if a key is up or down and then do this

if(keys&KEY_SPACE)
{
// space is pushed
}
if(keys&KEY_CTRL)
{
// ctrl is pushed
}

and so on

Share this post


Link to post
Share on other sites
Well I''m new to OpenGL but I''ve looked at nehe.gamedev.net and the way they get the keys in is really good. Make an array of booleans and when a key is pressed make it true, when a key is released make it false. Hope it helps.

Eric

Share this post


Link to post
Share on other sites

  • 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!