Keyboard input in MaxGUI

BlitzMax Forums/BlitzMax Programming/Keyboard input in MaxGUI

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.

Try this code
SuperStrict

Local MyWindow:TGadget=CreateWindow("Canvas Example", 200,200,320,240)
Local MyCanvas:TGadget=CreateCanvas(10,10,290,140,MyWindow)
ActivateGadget MyCanvas

Local x:Int=100
Local y:Int=10

Repeat
  WaitEvent()
  Select EventID()
  Case EVENT_WINDOWCLOSE
     End
  Case EVENT_KEYDOWN
	Select EventData()
	Case KEY_LEFT  x:- 3
	Case KEY_RIGHT x:+ 3
	EndSelect
    RedrawGadget(MyCanvas)
  Case EVENT_GADGETPAINT
    SetGraphics CanvasGraphics (MyCanvas)
    Cls
    DrawRect  x,y,40,40
    Flip
   End Select
Forever

You may want to go thru this two tutorials
http://www.2dgamecreators.com/maxgui/T12-Canvas.html
http://www.2dgamecreators.com/maxgui/Mouseevents.html
They are for mouse events but the principles are similar