If I intercept a key press using win32 calls, I now have a key code. Is there a way to convert that to a System.Windows.Forms.Keys value?
Asked
Active
Viewed 1.8k times
2 Answers
22
-
If the int and char keycode are interchangeable then this previous solution should work: link – xcud Feb 16 '09 at 20:59
-
The question was about WinForms; KeyInterop is a WPF class not available under WinForms – whale70 Jul 04 '18 at 02:26
10
The integer values for System.Windows.Forms.Keys enum match that of the Win32 calls.
Keys keyData = (Keys)rawWin32KeyCode;

Adam Larsen
- 1,121
- 1
- 8
- 13
-
This is not working if some modifier keys (shift, ctrl., alt) are pressed! lParam.vkCode = 160 // = VK_LSHIFT lParam.scanCode = 42 Keys key = (Keys)lParam.vkCode; key = Space | F17 – Jens Bornschein Jul 10 '18 at 13:44