|
-
Jul 2nd, 2013, 09:13 AM
#1
Thread Starter
Junior Member
How do I get keyboard scancodes and know it's an extended key?
Last edited by onidarbe; Jul 2nd, 2013 at 09:16 AM.
-
Jul 2nd, 2013, 09:58 AM
#2
Re: How do I get keyboard scancodes and know it's an extended key?
See the MapVirtualKey function.
 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:
 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:
 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.
Last edited by Bonnie West; Jul 2nd, 2013 at 01:18 PM.
Reason: Added API declaration
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jul 4th, 2013, 11:24 AM
#3
Thread Starter
Junior Member
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?
-
Jul 4th, 2013, 11:45 AM
#4
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!
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jul 4th, 2013, 12:19 PM
#5
Thread Starter
Junior Member
Re: How do I get keyboard scancodes and know it's an extended key?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|