Jump to content
  • Advertisement
Sign in to follow this  
dwfait

Keyboard input

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

This is in C++.. How do you get the raw input from the keyboard? Not from what the user has entered into the console, as i wish to exit as the user presses the Esc key.

Share this post


Link to post
Share on other sites
Advertisement
this question should be posted in the "for beginners" forum. Anyway if you want "raw" input in win32 OS you should check a library called DirectInput that is part of the biggest DirectX.

Share this post


Link to post
Share on other sites
If you only wish to check if the ESC key is down I think that initiating DirectInput is overkill. Instead, I would advice you to use this call:

if( 0x80 & GetAsyncKeyState( VK_ESCAPE ) )
// Escape key is down

You can get additional information at this page: GetAsyncKeyState Function

Don't forget to #include <windows.h>

Share this post


Link to post
Share on other sites
Or use windows messages for WM_KEYDOWN's or use SDL's input handler, or....

In short, there's no standard way to do this in C++, akin to reading a character.

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!