Skip to main content
GameDev.net gamedev.net
🔒 Locked

Windows keycode question

Started by DonnieDarko Aug 29, 2006 at 3:50 AM 1 replies 900+ views
Original Post
DonnieDarko
DonnieDarko
I'm registering key presses by WM_KEYDOWN messages sent to the window message handler. It's no problem regstering regular characters (A..Z) and special keys that has some predefined names like VK_F1 and VK_ADD but how can I register the '-' (subtract sign, not keypad subtract)? It turns out that '-' has the same integer value as VK_INSERT.
Jernej.L
Jernej.L
This is my mess on what i do to detect them:

// special key filtering...
oem:= (lparam and $FF0000) shr 16;
enchanged:= lparam and $1000000 = $1000000;

examples:

left shift: OEM code 42 -> 160
right shift: OEM code 54 -> 161

left ctrl: wparam: 17, enchanced = 0 -> 162
right ctrl: wparam: 17, enchanced = 1 -> 163

left alt: wparam: 18, enchanced = 0 -> 164
right alt: wparam: 18, enchanced = 1 -> 165

Return: wparam: 13, enchanced = 0 -> 13 (nothing to do)
Enter: wparam: 13, enchanced = 1 (?)

left win: 91, enchanced = 1
right win: 92, enchanced = 1

right popup menu: 93, enchanced = 1

cedilla: wparam = 192
tab: wparam = 15

and remember, to filter ALT key do this:

plug in these messages as wm_keydown/up and set Result to 0!!!
WM_SYSKEYDOWN
WM_SYSKEYUP

same applies to distinguishing the numpad keys.
Projects: Top Down City: http://mathpudding.com/
DonnieDarko
DonnieDarko
I have no problem distinguising between numpad keys as that can be done by VK_NUMPAD0 etc. I want to get the virtual key code for the '-' charater.

I have found the VkKeyScan function which can translate from ascii code to virtual key code (VkKeyScan(L'-'), so problem is now solved :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.