Page 1 of 1
'Missing' Keyboard Shortcuts for menu events ?
Posted: Tue Jan 01, 2013 11:18 am
by davido
I wished to use keyboard shortcuts in a menu for @#~= but could not find any #PB_Shortcut..... constants.
I tried 'cheating' by using the ascii number equivalent instead of the constant, but no joy.
Could these shortcuts be added to the system at some time.
@#~= Snoopy says please!
Only two wishes left, now!

Re: 'Missing' Keyboard Shortcuts for menu events ?
Posted: Tue Jan 01, 2013 1:22 pm
by Michael Vogel
The keys you are looking for, do not have a certain place on the keyboard, different language settings force different key combinations for accessing '#', '@' etc.
So depending on the abstraction level where you're scanning for the event, it will be needed to have different values for the same character (scan code for the pressed key, GetAsyncKeyState) or just something like the ASCII value (which can be checked by using the windows event #WM_CHAR).
Code: Select all
OpenWindow(0,100,100,320,100,"X", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_WindowCentered|#PB_Window_SizeGadget)
TextGadget(0,10,10,300,80, "Press key...",#ES_CENTER|#SS_CENTERIMAGE|#WS_BORDER)
Repeat
Select WaitWindowEvent()
Case #WM_CHAR
c=EventwParam()
s.s="Char "+Str(c)+" = '"+Chr(c)+"', Virtual Key(s):"
For i=1 To 255
If GetKeyState_(i)&128
s+Str(i)+" "
EndIf
Next i
SetGadgetText(0,s)
Case #PB_Event_CloseWindow
quit=1
EndSelect
Until quit
I found the following keys listed in a windows help file, I'm sure most of them are defined as PB constants
- VK_LBUTTON Left mouse button
VK_RBUTTON Right mouse button
VK_CANCEL Control-break processing
VK_MBUTTON Middle mouse button (three-button mouse)
VK_BACK BACKSPACE key
VK_TAB TAB key
VK_CLEAR CLEAR key
VK_RETURN ENTER key
VK_SHIFT SHIFT key
VK_CONTROL CTRL key
VK_MENU ALT key
VK_PAUSE PAUSE key
VK_CAPITAL CAPS LOCK key
VK_ESCAPE ESC key
VK_SPACE SPACEBAR
VK_PRIOR PAGE UP key
VK_NEXT PAGE DOWN key
VK_END END key
VK_HOME HOME key
VK_LEFT LEFT ARROW key
VK_UP UP ARROW key
VK_RIGHT RIGHT ARROW key
VK_DOWN DOWN ARROW key
VK_SELECT SELECT key
VK_EXECUTE EXECUTE key
VK_SNAPSHOT PRINT SCREEN key for Windows 3.0 and later
VK_INSERT INS key
VK_DELETE DEL key
VK_HELP HELP key
VK_0 0 key
VK_1 1 key
VK_2 2 key
VK_3 3 key
VK_4 4 key
VK_5 5 key
VK_6 6 key
VK_7 7 key
VK_8 8 key
VK_9 9 key
VK_A A key
VK_B B key
VK_C C key
VK_D D key
VK_E E key
VK_F F key
VK_G G key
VK_H H key
VK_I I key
VK_J J key
VK_K K key
VK_L L key
VK_M M key
VK_N N key
VK_O O key
VK_P P key
VK_Q Q key
VK_R R key
VK_S S key
VK_T T key
VK_U U key
VK_V V key
VK_W W key
VK_X X key
VK_Y Y key
VK_Z Z key
VK_LWIN Left Windows key (Microsoft Natural Keyboard)
VK_RWIN Right Windows key (Microsoft Natural Keyboard)
VK_APPS Applications key (Microsoft Natural Keyboard)
VK_NUMPAD0 Numeric keypad 0 key
VK_NUMPAD1 Numeric keypad 1 key
VK_NUMPAD2 Numeric keypad 2 key
VK_NUMPAD3 Numeric keypad 3 key
VK_NUMPAD4 Numeric keypad 4 key
VK_NUMPAD5 Numeric keypad 5 key
VK_NUMPAD6 Numeric keypad 6 key
VK_NUMPAD7 Numeric keypad 7 key
VK_NUMPAD8 Numeric keypad 8 key
VK_NUMPAD9 Numeric keypad 9 key
VK_MULTIPLY Multiply key
VK_ADD Add key
VK_SEPARATOR Separator key
VK_SUBTRACT Subtract key
VK_DECIMAL Decimal key
VK_DIVIDE Divide key
VK_F1 F1 key
VK_F2 F2 key
VK_F3 F3 key
VK_F4 F4 key
VK_F5 F5 key
VK_F6 F6 key
VK_F7 F7 key
VK_F8 F8 key
VK_F9 F9 key
VK_F10 F10 key
VK_F11 F11 key
VK_F12 F12 key
VK_F13 F13 key
VK_F14 F14 key
VK_F15 F15 key
VK_F16 F16 key
VK_F17 F17 key
VK_F18 F18 key
VK_F19 F19 key
VK_F20 F20 key
VK_F21 F21 key
VK_F22 F22 key
VK_F23 F23 key
VK_F24 F24 key
VK_NUMLOCK NUM LOCK key
VK_SCROLL SCROLL LOCK key
VK_ATTN Attn key
VK_CRSEL CrSel key
VK_EXSEL ExSel key
VK_EREOF Erase EOF key
VK_PLAY Play key
VK_ZOOM Zoom key
VK_NONAME Reserved for future use.
VK_PA1 PA1 key
VK_OEM_CLEAR Clear key
Re: 'Missing' Keyboard Shortcuts for menu events ?
Posted: Tue Jan 01, 2013 3:20 pm
by davido
Michael,
Thanks again for you help.
Beautiful demo. I will now be able to make it work in windows os.
I like to make my programs cross-platform as I use both Linux and Windows which is why I made the request. However, the windows version is the most important.
regards
Dave
Re: 'Missing' Keyboard Shortcuts for menu events ?
Posted: Wed Jan 02, 2013 12:13 am
by Demivec
Here's another way to obtain the shortcuts using an example from the PB manual for the 'ShortcutGadget'.
Code: Select all
If OpenWindow(0, 0, 0, 240, 70, "ShortcutGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ShortcutGadget(0, 20, 20, 200, 25, #PB_Shortcut_Control | #PB_Shortcut_A)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
Re: 'Missing' Keyboard Shortcuts for menu events ?
Posted: Wed Jan 02, 2013 8:04 am
by davido
Hi Demivec,
Thank you for your help.
I hadn't looked at this gadget before; seems very interesting.
Regards
Dave