Archived

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

CompuWizJacob

Input response

Recommended Posts

How would you make it so the computer takes in and processes a key right after its pressed, instead of the user having to push ? Example: There is a menu like this: new load exit What would you like to do?: Say, the user pushed . The computer responds instantly and opens a new file.

Share this post


Link to post
Share on other sites
There''s a lot of ways to do this, all depending on what you''re using. Although you seem to be using the console, since you mentionned text menus.

If memory serves right, you''d have to use Getch() (stdlib.h methinks).

In the case of Windows programming with no window at all, you can try GetAsyncKeyState();

if(!(GetAsyncKeyState(27) & 0x8000))
{
//the escape key is being held down
}
if(GetAsyncKeyState(27) & 0x8000)
{
//the escape key isn''t being held down
}

This was all done from memory though I''m pretty sure it''s mostly accurate. At worse I might have gotten the ! in GetAsyncKeyState reversed.

Share this post


Link to post
Share on other sites