[esc] in a textfield

BlitzPlus Forums/BlitzPlus Programming/[esc] in a textfield

How do I read out an [esc] press while typing in a textfield ? :)

a$=RequestString$(256,256,80,24,"Blah!")
Notify a$
End


Function RequestString$(x,y,width,height,def$="")

	FlushEvents()
	FlushKeys()

	w=CreateWindow("",x,y,width,height,0,0)
	
	txt=CreateTextField(1,1,width-2,height-2,w)
	SetGadgetText txt,def$
	ActivateGadget txt
	Repeat
		WaitEvent()
		
		If EventID()=$803
			If EventSource()=w quit=True
		EndIf
		
		If EventSource()=txt
			If EventID()=$401
				If EventData()=13 ; enter
					quit=True
					returnstring$=TextFieldText(txt)
				EndIf
				If EventData()=27 ; esc
					End ; <-debug
					quit=True
					returnstring$=def$
				EndIf
			EndIf
		EndIf
	Until quit

	FreeGadget w	
	
	Return returnstring$
	
End Function