How do I get keyboard scancodes and know it's an extended key?
Re: How do I get keyboard scancodes and know it's an extended key?
See the MapVirtualKey function.
Quote:
Originally Posted by MSDN
Translates (maps) a virtual-key code into a scan code or character value, or translates a scan code into a virtual-key code.
Code:
Private Enum MapVKTypeConstants
MAPVK_VK_TO_VSC = 0
MAPVK_VSC_TO_VK = 1
MAPVK_VK_TO_CHAR = 2
MAPVK_VSC_TO_VK_EX = 3
End Enum
#If False Then
Dim MAPVK_VK_TO_VSC, MAPVK_VSC_TO_VK, MAPVK_VK_TO_CHAR, MAPVK_VSC_TO_VK_EX
#End If
Private Declare Function MapVirtualKeyW Lib "user32.dll" (ByVal uCode As Long, ByVal uMapType As MapVKTypeConstants) As Long
EDIT
From the WM_KEYDOWN/WM_KEYUP messages:
Quote:
Originally Posted by MSDN
For enhanced 101- and 102-key keyboards, extended keys are the right ALT and CTRL keys on the main section of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and arrow keys in the clusters to the left of the numeric keypad; and the divide (/) and ENTER keys in the numeric keypad. Other keyboards may support the extended-key bit in the lParam parameter.
EDIT 2
Also from the Keystroke Message Flags:
Quote:
Originally Posted by MSDN
Extended-Key Flag
The extended-key flag indicates whether the keystroke message originated from one of the additional keys on the enhanced keyboard. The extended keys consist of the ALT and CTRL keys on the right-hand side of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and arrow keys in the clusters to the left of the numeric keypad; the NUM LOCK key; the BREAK (CTRL+PAUSE) key; the PRINT SCRN key; and the divide (/) and ENTER keys in the numeric keypad. The extended-key flag is set if the key is an extended key.
Re: How do I get keyboard scancodes and know it's an extended key?
So rather then a api telling if a key is an extended key, I need to make a list of them, because there are always the same no matter what keyboard, right?
Re: How do I get keyboard scancodes and know it's an extended key?
Well, checking if a key belongs to the extended key list would seem to be the easiest way. However, MSDN mentions that "Other keyboards may support the extended-key bit in the lParam parameter." so, that method isn't very reliable. I haven't been able to find the proper solution yet, but in the meantime, that method should suffice for most purposes. Sorry!
Re: How do I get keyboard scancodes and know it's an extended key?