AddKeyboardShortcut ADDITIONS

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

AddKeyboardShortcut ADDITIONS

Post by Rook Zimbabwe »

I have gotten used to the way to BIND keyboard input in my application using the AddKeyboardShortcut command... It seems to me there are a few buttons left off the list that might be added to the list if possible:

#PB_Shortcut_Enter

#PB_Shortcut_PadEnter

:)
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

When you say #PB_Shortcut_Enter do you mean the enter key on the main keyboard, if you do then it is #PB_Shortcut_Return.

As for the pad enter, I think you're right, there doesn't seem to be a shortcut for it.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

The numpad enter does not have a virtual key, it is the same as the normal return (enter) key.

Here is some code to test/support enhanced keyboards (aka Media/Internet keyboards)
These are the "missing" PB virtual keycodes,
please note that there are more virtual key codes than these but they are either not keys or very special keys.
Also note that not all of these may work (see inline comments for results on my own test)

Maybe the PB Team can add some of these,
I was surprised that LaunchApp1 was not available for me but LaunchApp2 was though. (in my case LaunchApp1 starts the calculator)

Note, I use default Windows driver and not logitech's drivers, so in my case the zoom key do not work due to that.

Code: Select all

CompilerIf #PB_Compiler_OS=#PB_OS_Windows
 ;Windows Virtual-Key Codes
 #PB_Shortcut_LeftShift=$A0 ;Left SHIFT key
 #PB_Shortcut_RightShift=$A1 ;Right SHIFT key
 #PB_Shortcut_LeftControl=$A2 ;Left CONTROL key
 #PB_Shortcut_RightControl=$A3 ;Right CONTROL key
 #PB_Shortcut_LeftMenu=$A4 ;Left MENU key
 #PB_Shortcut_RightMenu=$A5 ;Right MENU key
 #PB_Shortcut_BrowserBack=$A6 ;Windows 2000/XP: Browser Back key
 #PB_Shortcut_BrowserForward=$A7 ;Windows 2000/XP: Browser Forward key
 #PB_Shortcut_BrowserRefresh=$A8 ;Windows 2000/XP: Browser Refresh key
 #PB_Shortcut_Stop=$A9 ;Windows 2000/XP: Browser Stop key
 #PB_Shortcut_BrowserSearch=$AA ;Windows 2000/XP: Browser Search key 
 #PB_Shortcut_BrowserFavorites=$AB ;Windows 2000/XP: Browser Favorites key
 #PB_Shortcut_BrowserHome=$AC ;Windows 2000/XP: Browser Start And Home key
 #PB_Shortcut_VolumeMute=$AD ;Windows 2000/XP: Volume Mute key
 #PB_Shortcut_VolumeDown=$AE ;Windows 2000/XP: Volume Down key
 #PB_Shortcut_VolumeUp=$AF ;Windows 2000/XP: Volume Up key
 #PB_Shortcut_MediaNextTrack=$B0 ;Windows 2000/XP: Next Track key
 #PB_Shortcut_MediaPrevTrack=$B1 ;Windows 2000/XP: Previous Track key
 #PB_Shortcut_MediaStop=$B2 ;Windows 2000/XP: Stop Media key
 #PB_Shortcut_MediaPlayPause=$B3 ;Windows 2000/XP: Play/Pause Media key
 #PB_Shortcut_LaunchMail=$B4 ;Windows 2000/XP: Start Mail key
 #PB_Shortcut_LaunchMediaSelect=$B5 ;Windows 2000/XP: Select Media key
 #PB_Shortcut_LaunchApp1=$B6 ;Windows 2000/XP: Start Application 1 key
 #PB_Shortcut_LaunchApp2=$B7 ;Windows 2000/XP: Start Application 2 key
 #PB_Shortcut_Attn=$F6 ;Attn key
 #PB_Shortcut_CrSel=$F7 ;CrSel key
 #PB_Shortcut_ExSel=$F8 ;ExSel key
 #PB_Shortcut_EraseEOF=$F9 ;Erase EOF key
 #PB_Shortcut_Play=$FA ;Play key
 #PB_Shortcut_Zoom=$FB ;Zoom key
 #PB_Shortcut_PA1=$FD ;PA1 key
CompilerEndIf

If OpenWindow(0,100,200,195,260,"PureBasic Window",#PB_Window_SystemMenu|#PB_Window_MinimizeGadget)
 ;Tested ok on my system
 AddKeyboardShortcut(0,#PB_Shortcut_VolumeMute,14)
 AddKeyboardShortcut(0,#PB_Shortcut_VolumeDown,15)
 AddKeyboardShortcut(0,#PB_Shortcut_VolumeUp,16)
 AddKeyboardShortcut(0,#PB_Shortcut_MediaNextTrack,17)
 AddKeyboardShortcut(0,#PB_Shortcut_MediaPrevTrack,18)
 AddKeyboardShortcut(0,#PB_Shortcut_MediaStop,19)
 AddKeyboardShortcut(0,#PB_Shortcut_MediaPlayPause,20)
 AddKeyboardShortcut(0,#PB_Shortcut_LaunchMail,21)
 AddKeyboardShortcut(0,#PB_Shortcut_LaunchMediaSelect,22)
 AddKeyboardShortcut(0,#PB_Shortcut_LaunchApp2,24)
 AddKeyboardShortcut(0,#PB_Shortcut_BrowserSearch,11)
 AddKeyboardShortcut(0,#PB_Shortcut_BrowserFavorites,12)
 AddKeyboardShortcut(0,#PB_Shortcut_BrowserHome,13)

 ;Not tested (failed or no such keys available on this keyboard)
 AddKeyboardShortcut(0,#PB_Shortcut_LaunchApp1,23)
 AddKeyboardShortcut(0,#PB_Shortcut_LeftShift,1)
 AddKeyboardShortcut(0,#PB_Shortcut_RightShift,2)
 AddKeyboardShortcut(0,#PB_Shortcut_LeftControl,3)
 AddKeyboardShortcut(0,#PB_Shortcut_RightControl,4)
 AddKeyboardShortcut(0,#PB_Shortcut_LeftMenu,5)
 AddKeyboardShortcut(0,#PB_Shortcut_RightMenu,6)
 AddKeyboardShortcut(0,#PB_Shortcut_BrowserBack,7)
 AddKeyboardShortcut(0,#PB_Shortcut_BrowserForward,8)
 AddKeyboardShortcut(0,#PB_Shortcut_BrowserRefresh,9)
 AddKeyboardShortcut(0,#PB_Shortcut_Stop,10)
 AddKeyboardShortcut(0,#PB_Shortcut_Attn,25)
 AddKeyboardShortcut(0,#PB_Shortcut_CrSel,26)
 AddKeyboardShortcut(0,#PB_Shortcut_ExSel,27)
 AddKeyboardShortcut(0,#PB_Shortcut_EraseEOF,28)
 AddKeyboardShortcut(0,#PB_Shortcut_Play,29)
 AddKeyboardShortcut(0,#PB_Shortcut_Zoom,30)
 AddKeyboardShortcut(0,#PB_Shortcut_PA1,31)

 Repeat
  windowevent=WaitWindowEvent()
  If windowevent=#PB_Event_Menu
   eventmenu=EventMenu()
   Select eventmenu
    Case 1
     Debug "Left SHIFT key"
    Case 2
     Debug "Right SHIFT key"
    Case 3
     Debug "Left CONTROL key"
    Case 4
     Debug "Right CONTROL key"
    Case 5
     Debug "Left MENU key"
    Case 6
     Debug "Right MENU key"
    Case 7
     Debug "Browser Back key"
    Case 8
     Debug "Browser Forward key"
    Case 9 
     Debug "Browser Refresh key"
    Case 10
     Debug "Browser Stop key"
    Case 11
     Debug "Browser Search key "
    Case 12
     Debug "Browser Favorites key"
    Case 13
     Debug "Browser Start And Home key"
    Case 14
     Debug "Volume Mute key"
    Case 15
     Debug "Volume Down key"
    Case 16
     Debug "Volume Up key"
    Case 17
     Debug "Next Track key"
    Case 18
     Debug "Previous Track key"
    Case 19
     Debug "Stop Media key"
    Case 20
     Debug "Play/Pause Media key"
    Case 21
     Debug "Start Mail key"
    Case 22
     Debug "Select Media key"
    Case 23
     Debug "Start Application 1 key"
    Case 24
     Debug "Start Application 2 key"
    Case 25
     Debug "Attn key"
    Case 26
     Debug "CrSel key"
    Case 27
     Debug "ExSel key"
    Case 28
     Debug "Erase EOF key"
    Case 29
     Debug "Play key"
    Case 30
     Debug "Zoom key"
    Case 31
     Debug "PA1 key"
    Default
     Debug "Unknown"
   EndSelect
  EndIf

 Until windowevent=#PB_Event_CloseWindow
  
EndIf

End
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

#PB_Shortcut_Return.
BANG BANG BANG...

{banging my head again...}

Oy!

I am a gonna try that...
Post Reply