WaitKey_or_Mouse()

BlitzMax Forums/BlitzMax Beginners Area/WaitKey_or_Mouse()

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 wanted a function that would combine Waitkey and Waitmouse.
After looking at the source code, I put this together and to my complete astonishment it seems to work.

Is this a good place to post this?
What about making it a regular part of BlitzMax?


' Function that waits for a key press or mouse click
' Mouse keys are returned as 255 + mouse key code

Function WaitKey_Or_Mouse()
Local n%
FlushKeys ; FlushMouse
Repeat
WaitSystem
For n=1 To 255
If KeyHit(n) Return n
Next
For n=1 To 3
If MouseHit(n) Return n + 255
Next
Forever
End Function