; GetKey Example ; -------------- Graphics 640,480,0,2 SetBuffer BackBuffer() typed$="" last_key=0 While Not KeyDown(1) Cls ; GetKey returns the ASCII code of the next key waiting in the ; keyboard buffer, or 0 if no key has been pressed. k=GetKey() If k>0 Then last_key=k ; Printable characters (ASCII 32..126) build a typing preview If k>=32 And k<=126 Then typed$=typed$+Chr$(k) ; Backspace (ASCII 8) deletes the last character If k=8 And Len(typed$)>0 Then typed$=Left$(typed$,Len(typed$)-1) Text 0,0,"Type something Backspace: delete Esc: exit" If last_key=0 Then Text 0,20,"Waiting for the first key..." Else Text 0,20,"Last GetKey() code: "+last_key End If If last_key>=32 And last_key<=126 Then Text 0,40,"That is the character '"+Chr$(last_key)+"'" Text 0,80,"You typed: "+typed$+"_" Flip Wend End