PDA

Click to See Complete Forum and Search --> : How do i check to see if a key is being pressed?


Aug 30th, 2000, 11:38 PM
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...

Aug 31st, 2000, 08:37 AM
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');
}