I'm trying to just stop my program whenever ESC Key is pressed.
For example i have code like this :
char key;
char msg[20];
printf("\n\n\t\t press escape to quit\n\n");
do {
key = _getch();
if (key == ESC) {
printf("Key: ESCAPE");
putchar('\n');
}
else {
printf("Key: %c", key);
putchar('\n');
}
Sleep(5000);
} while (key != ESC);
return 0;
And now when i need to exit my program instantly whenever i press ESC is it possible to do? My program gonna exit after 5 sec.. after
Sleep(5000)
All i want to do is exit program instantly when ESC is pressed.
How can i do that?