Either you dont use any loops at all and put in a wait key statement... Which is essentially a loop in itself that continously loops checking for a keypress - you could make your own wait key command that waits for a specific key to continue, like this:
REPEAT UNTIL KEYSTATE( key )
Replacing the key variable with the scancode of the key you want to detect. You could expand it to accept multiple keys with a simple addition statement:
REPEAT UNTIL KEYSTATE(key1) + KEYSTATE(key2) + KEYSTATE(key3) > 0
Etc... or if you wanted it to be more efficient you could store all of the keys you want to check for inside an array and check for these keys in a for...loop inside the repeat loop like this:
DIM key(3)
key(1) = 2
key(2) = 3
key(3) = 4
REPEAT
FOR k = 1 TO 3
IF KEYSTATE( key(k) ) = 1 THEN pressed = 1:EXIT
NEXT k
UNTIL pressed
OR just use wait key, eg;
PRINT "Code that runs before the escapekey"
WAIT KEY
END
The benefit with creating your own command to wait for a key is that you CAN put it inside a loop and have other things continue happening while it waits for the escapekey, instead of halting the program to wait for a key like the wait key does.