Select Case KeyDown?
BlitzMax Forums/BlitzMax Beginners Area/Select Case KeyDown?
| ||
How would I use a select case for keydown? I would use if but isn't select faster? if so. Why does this code not work. And what is the right way? DXRenderType = TnL Graphics 640,480,0 refreshTimer:TTimer = CreateTimer(60) Repeat WaitEvent() Select EventID() Case EVENT_TIMERTICK KEY = GetChar() Select KEY Case KeyDown(KEY_UP) Cls DrawText "UP Pressed", 10, 10 Flip Case KeyDown(KEY_DOWN) Cls DrawText "DOWN Pressed", 10, 10 Flip Case KeyDown(KEY_LEFT) Cls DrawText "LEFT Pressed", 10, 10 Flip Case KeyDown(KEY_RIGHT) Cls DrawText "RIGHT Pressed", 10, 10 Flip Default Cls DrawText "Nothing Pressed", 10, 10 Flip EndSelect EndSelect Until KeyHit(KEY_ESCAPE) Or AppTerminate() |
| ||
This'll work... |
| ||
Or try thisGraphics 640,480,0 Repeat WaitEvent() Select EventID() Case EVENT_KEYDOWN Select EventData() Case KEY_UP Cls DrawText "UP Pressed", 10, 10 Flip Case (KEY_DOWN) Cls DrawText "DOWN Pressed", 10, 10 Flip Case (KEY_LEFT) Cls DrawText "LEFT Pressed", 10, 10 Flip Case KEY_RIGHT Cls DrawText "RIGHT Pressed", 10, 10 Flip Default Cls DrawText "Nothing Pressed", 10, 10 Flip End Select End Select Until KeyHit(KEY_ESCAPE) Or AppTerminate() |
| ||
aha. thanks ernie. you too assari! for your site as well. Ill use ernies because i want it checked when the timer ticks. its for a game im trying to make. but thanks! |