Click to See Complete Forum and Search --> : How do i check to see if a key is being pressed?
How do i check to see if a key is being pressed while in a "while()" loop?
parksie
Aug 31st, 2000, 08:11 AM
If you're in a Windows app - your window will receive a WM_CHAR message.
For console apps, try the getch() function. Unfortunately I think that doesn't return until a key is pressed...
Use the _getch function.
#include <conio.h>
#include <ctype.h>
void main()
{
char ch;
_cputs( "Enter a letter: " );
// Loop until "Y" is pressed
do
{
ch = _getch();
ch = toupper( ch );
}
while( ch != 'Y');
}
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.