Keyboard catcher example on a form

Just starting out? Need help? Post your questions and find answers here.
AngelSoul
User
User
Posts: 55
Joined: Tue Jul 29, 2003 9:16 am
Location: Canada

Keyboard catcher example on a form

Post 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
-----------------------------------------------
AMD 1.8 - 512mb - ATI All-In-Wonder Radeon 9000 pro - W2k Pro
BASIC programmers never die, they just return without gosub.
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

thank you.
I could use this sometime.
Joe
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
Post Reply