Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert from Virtual Key codes to System.Windows.Forms.Keys

Tags:

c#

.net

key

winapi

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?

like image 625
Jeremy Avatar asked Feb 16 '09 18:02

Jeremy


2 Answers

Use KeyInterop.KeyFromVirtualKey().

like image 200
xcud Avatar answered Oct 22 '22 02:10

xcud


The integer values for System.Windows.Forms.Keys enum match that of the Win32 calls.

Keys keyData = (Keys)rawWin32KeyCode;
like image 44
Adam Larsen Avatar answered Oct 22 '22 01:10

Adam Larsen