How to trap ANY key pressed?

Blitz3D Forums/Blitz3D Programming/How to trap ANY key pressed?

Boiled Sweets(Posted 2005) [#1]
Hi is there a clever way to see if ANY key has been pressed without a wait? The GetKey does not trap keys that don't return an ascii value (i.e. shift, control etc) so that cannot be used.

Any thoughts?


tonyg(Posted 2005) [#2]
Does this help...
Graphics 640,480
SetBuffer BackBuffer()
While Not KeyHit(1)
   Cls 
   my_key=getmykey()
   If my_key=0
       Text 0,0,"No key hit"
   Else
       Text 0,0,my_key
   EndIf
   Flip
   WaitKey()
; Take out waitkey for keydown for better test.
Wend
End
Function getmykey()
	For x = 1 To 237
	    If KeyHit(x) Return x
;           If keydown(x) return x
	Next
End Function



Snarkbait(Posted 2005) [#3]
Odd, my keyboard doesn't have an 'ANY' key... :P


Hotcakes(Posted 2005) [#4]
I'm feeling thirsty. I think I'll order a TAB. Oh! No time for that now, the computer's starting!


Boiled Sweets(Posted 2005) [#5]
Doh! My thinking cap is at the dry cleaners. It was bloody obvious - thanks tonyg.