In my application I am displaying images using an infinite while loop. I want to break the while loop whenever a predefined key is pressed. I have tried using GetAsyncKeyState()
if (GetAsyncKeyState(VK_ESCAPE))
{
break;
printf("Exiting Loop\n");
}
But this is not working!!
The second approach I have used is to get the ascii value of the key using getch() method. So something like this,
# include conio.h // Required header file
int keyVal;
keyVal = getch();
if (keyVal == 27)
{
break;
}
However, this approach is making my application non-responsive.
Any ideas about how to break the while loop using keyboard events or mouse events? It could be any key.
Thanks in advance.