Is There A Way To...

Miscellaneous Forums/General Discussion/Is There A Way To...

... check to see if any key has been hit in Blitz or Blitz3D... to avoid a long list of checking incase no key wasn't pressed...

thx

--Mike

Try
Repeat
If GetKey() <> 0 Then End
Delay 10
Forever


thx...

(momentary brain lock... too much shoveling snow today)

--Mike

Or just
WaitKey


http://blitzbasic.com/b3ddocs/command_list_2d_cat.php?show=Input

Yea, that too. I must be having a brain lock myself.

GetKey() doesn't work with function keys anyway, but Waitkey halts execution

Neither does WaitKey(). I think it does exactly what your code does - maybe with a different delay mechanism.

If you need something that works for function keys (and shift keys!) you could try

Function WaitAnyKey()
	While True
		For i = 1 To 237 ; last known scancode
			If KeyDown(i) Then Return
		Next
		Delay 1
	Wend
End Function


Note that this function doesn't strip the character off the GetKey buffer like WaitKey() does.