[MS] How can I distinguish between the numeric keypad 0 and the top-row 0 in the WM_CHAR message? - devamazonaws.blogspot.com
Last time, we looked at how to distinguish the numeric keypad 0 and the top-row 0 in the WM_ KEYDOWN message . We may as well look at the analogous table for WM_ CHAR . Event wParam Extended? Numpad0 with NumLock on VK_0 0 Numpad0 with NumLock off (no WM_CHAR ) Ins key (no WM_CHAR ) 0 on top row VK_0 0 I got the name VK_0 from this comment block in winuser.h . /* * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39) * 0x3A - 0x40 : unassigned * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A) */ Uh-oh. The extended bit doesn't distinguish between the two. They both show up as VK_0 , non-extended. What changes is something not in the above table: The scan code. So let's convert the scan code back to a virtual key. auto vk_from_scan = MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK); Event wParam Extended? vk_from_scan Numpad0 with NumLock on VK_0 0 VK_INSERT Num...