I have a WinForm application where I need to capture a KeyPress and fetch the scancode for it. Along with that I need to convert existing scancodes int key names (by converting to virtual keys beforehand perhaps?) Is there any way to accomplish this?
Share
The first part is possible, but tricky, because multiple Virtual Key (VK) codes will map to the same scancode (depending on the keyboard shift/ctrl/alt state).
I’m not sure what you mean by “key name,” but if you’re referring to the physical keyboard layout then, for your next step, you will need to make some assumptions about the key’s location based on standard physical keyboard layouts (101-key, 102-key etc).
See my answer to this question for some sample code and a more detailed description.