Keyboard catcher example on a form
Posted: Wed Jul 30, 2003 7:04 am
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. 
-----------------------------------------------
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
-----------------------------------------------
-----------------------------------------------
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
-----------------------------------------------