getmouse() and getkey() alternatives.

BlitzMax Forums/BlitzMax Beginners Area/getmouse() and getkey() alternatives.

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.

Well, you have GetChar() to check keyboard input, although this is mainly keys with ASCII codes. If you want to check for all scancodes then you could use...

Function GetKey:Int()
  Local key:Int=-1
  For Local i:Int = 0 to 255
    If KeyHit(i) Then key=i;Exit
  Next
  Return key
End Function
Where -1 would indicate no key was pressed and anything else would return the key code (not the usual scancode) of the key.

I wouldn't have thought this necessary in a screensaver though, as I don't think that many people would press anything other then Space or Return to get out. Unless you have something else in mind.

As for the mouse, the 3 mouse buttons actually have key codes (or you could use the usual MouseHit or MouseDown). As for the movement, simply keep track of the last known X and Y co-ordinates and if they change the next frame you know the mouse has moved.

Hope that helps a little.