Using escape key to exit loop

Back in BASIC I could program:

1: code;
2: if anykey$=ESC goto 1 else goto 3;
3: rest of code;

obviously since we don't point to line numbers anymore, there isn't something equivalent. What I'm wondering is if there is a way to check for a certain key being pushed without waiting for input? I know I could do:

char ans;
while(ans=='y'){
code;
and=cin.get();}

But I want the codo to keep running without pausing.
Topic archived. No new replies allowed.