Page 1 of 1

Keyboard catcher example on a form

Posted: Wed Jul 30, 2003 7:04 am
by AngelSoul
I've been searching a lot on how to catch keys in a form, i've come up with a simple and short method and i'd like to share it with those who still doesn't know how. :D


-----------------------------------------------
Main = OpenWindow(1, 0, 0, 320, 200, #PB_Window_MinimizeGadget, "My Form")

repeat
Event=WindowEvent()
If Event=256 ;Keypress detected
kk=EventwParam() ;Value of the key in ascii
EndIf
If kk=27 ;if ESC key is pressed, terminate application
End
EndIf

delay(1) ;don't take all CPU power
forever
-----------------------------------------------

Posted: Wed Jul 30, 2003 9:10 pm
by TronDoc
thank you.
I could use this sometime.
Joe