I saw KeyboardInkey() returns the last typed character, but I want my program to react when I press Alt, Shift, F1->F12, Ctrl etc...
How do I do that?
Thanks.
How to catch system keys
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
-
- PureBasic Expert
- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
The keyboard library uses Direct-X iirc.
If you don't need / want it, you may have a look at GetAsyncKeyState_() (Windows API).
If you don't need / want it, you may have a look at GetAsyncKeyState_() (Windows API).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
If you're making a gui (window with gadgets) and you're processing the keypresses while your program is focused, probably the best way is to use AddKeyboardShortCut():
Code: Select all
#ControlF5 = 1
OpenWindow(0,0,0,320,240,"Keyboard Shortcut Demo",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
; add gadgets here
AddKeyboardShortcut(0, #PB_Shortcut_Control|#PB_Shortcut_F5, #ControlF5)
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Menu
Select EventMenu()
Case #ControlF5
Debug "You pressed Control-F5!"
EndSelect
EndSelect
Until EventID = #PB_Event_CloseWindow
BERESHEIT