While Keyhit waiting problems

BlitzMax Forums/BlitzMax Beginners Area/While Keyhit waiting problems

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Hi,
I have code that I want only to exit if the user presses the ESX button.So I have a main loop like so:
While NOT KeyHit(KEY_ESCAPE)
c64(MilliSecs())
Wend

This is fine but each of these functions contain while loops and while these loops are running pressing the escape key does nothing.Am I missing something here ?

Graphics 800,600,0
HideMouse
While NOT KeyHit(KEY_ESCAPE)
   c64(MilliSecs())
   fade()
   SnowFlake(MilliSecs())
Wend

'-----------------------------------------'

Function c64(timerval:Int)
  While timerval+15000 > MilliSecs()
	  Cls
       
 Local y=0,h
        Repeat
                h=Rand(5,60)
                SetColor Rand(255),Rand(255),Rand(255)
                DrawRect 0,y,GraphicsWidth(),h
                y:+h
        Until y>=GraphicsHeight()
	  Flip
  Wend
End Function