How to handle a keypress

BlitzPlus Forums/BlitzPlus Programming/How to handle a keypress

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I have a message handler like this:
Repeat
	EvntID = WaitEvent()
	Select EvntID
		Case $102
			If EventData() = 1
				result = Confirm("Terminate Game?")
				If result = True Then End
			EndIf
	End Select
Forever
and it pops up the Confirm box when I press the escape key. The problem is if I click on a button, and then press the escape key, the Confirm box does not pup up.

What am I doing wrong? How do I make it so that at any time the user can press the escape key and the Confirm box will pop up?