Stopping codes with a key press

Hello, I have a program that I made, which does a list of stuff, then checks if a key is pressed, and if it's pressed, stop the looping.
The problem is, it checks if the key is pressed once a loop, which means that if the list has delays, you have to hold the button down for a while (depending on the list).
Here's an example:
Move mouse;
Pause program for 2 seconds;
Move mouse;
Pause program for 2 seconds;
Check if key is pressed;
What ways can I fix this problem?
If you are using a compiler which has "conio.h" you can use kbhit() function.
Topic archived. No new replies allowed.