Page 1 of 1
					
				Problem with Virtual Keys
				Posted: Sun Dec 19, 2010 10:03 pm
				by charvista
				I am writing a kind of text editor, so I need to be able to capture every keystroke.
Some keys seem not to have a virtual key, like the comma (,) semicolon(:) or dot(.) (and some more).
So, how can I know when the user presses the comma key?
A standard way that will load the value 1036 in the Home key:
Code: Select all
AddKeyboardShortcut(Win,#PB_Shortcut_Home,1036)
In the event loop, it is then captured:
Code: Select all
  Repeat
    Event=WaitWindowEvent()
    Select Event
        Case #PB_Event_Menu
            KeyCode=EventMenu()
            If KeyCode=1036
etc......
Thanks in advance
Cheers
 
			 
			
					
				Re: Problem with Virtual Keys
				Posted: Mon Dec 20, 2010 12:42 am
				by LuCiFeR[SD]
				#VK_OEM_PERIOD (Full stop/Period or dot as you call it)
#VK_OEM_COMMA (Comma)
#VK_OEM_1 (For colon and semicolon ";:") <<<== US Keyboards?
MSDN is your friend
 
			 
			
					
				Re: Problem with Virtual Keys
				Posted: Mon Dec 20, 2010 1:26 am
				by charvista
				Thank you so much Lucifer, together with MSDN you are also a good friend  
 
I could remap all of the important keys, except one. That's the "<>\" key on the French (Belgian) keyboard. I believe this is the "|\" key on the US keyboard. What is its value?
 
			 
			
					
				Re: Problem with Virtual Keys
				Posted: Mon Dec 20, 2010 1:40 am
				by charvista
				No, it is not the "|\" key on the US keyboard, as this one is #VK_OEM_5.
The Virtual key for the "<>\" on the Belgian keyboard is #VK_OEM_102. It appears undocumented in the MSDN, but I found it in the Structure Viewer from PB!!!
Cheers
			 
			
					
				Re: Problem with Virtual Keys
				Posted: Mon Dec 20, 2010 3:04 am
				by LuCiFeR[SD]
				you are very welcome charvista.  Glad I could be of assistance 

 
			 
			
					
				Re: Problem with Virtual Keys
				Posted: Fri Aug 04, 2017 11:39 pm
				by Karig
				This is an ancient thread 

 , but in case anyone's searching how to use the odd punctuation keys with AddKeyboardShortcut in Linux, here is some code that works on both my Windows machine and my Linux laptop:
Code: Select all
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  #KEY_COMMA         = 44 ; Asc(",")
  #KEY_PERIOD        = 46 ; Asc(".")
  #KEY_SLASH         = 47 ; Asc("/")
  #KEY_SEMICOLON     = 59 ; Asc(";")
  #KEY_QUOTE         = 39 ; Asc("'")
  #KEY_LEFT_BRACKET  = 91 ; Asc("[")
  #KEY_RIGHT_BRACKET = 93 ; Asc("]")
  #KEY_BACKSLASH     = 92 ; Asc("\")
  #KEY_BACKTICK      = 96 ; Asc("`")
CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
  ; REFERENCE: http://msdn.microsoft.com/en-us/library/dd375731(VS.85).aspx
  #KEY_COMMA         = #VK_OEM_COMMA
  #KEY_PERIOD        = #VK_OEM_PERIOD
  #KEY_SLASH         = #VK_OEM_2
  #KEY_SEMICOLON     = #VK_OEM_1
  #KEY_QUOTE         = #VK_OEM_7
  #KEY_LEFT_BRACKET  = #VK_OEM_4
  #KEY_RIGHT_BRACKET = #VK_OEM_6
  #KEY_BACKSLASH     = #VK_OEM_5
  #KEY_BACKTICK      = #VK_OEM_3
CompilerEndIf
(So you can add the #PB_Shortcut_Control|#KEY_PERIOD if you want that to do something. 

 )
I don't have a Mac, or I'd be motivated to figure out what the values should be for the Mac.
 
			 
			
					
				Re: Problem with Virtual Keys
				Posted: Fri Aug 04, 2017 11:47 pm
				by netmaestro
				Nothing wrong with your code, but in PB shorthand:
',' is eqivalent to Asc(",")