Skip to content

Instantly share code, notes, and snippets.

@wongsyrone
Created September 13, 2016 13:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wongsyrone/424dd6b12da3e8276cae39c515af6856 to your computer and use it in GitHub Desktop.
Save wongsyrone/424dd6b12da3e8276cae39c515af6856 to your computer and use it in GitHub Desktop.
Convert between System.Windows.Forms.Keys and System.Windows.Input.Key
Keys formsKey = Keys.A;
Key wpfKey = Key.A;
wpfKey = KeyInterop.KeyFromVirtualKey((int)formsKey);
formsKey = (Keys)KeyInterop.VirtualKeyFromKey(wpfKey);
// The KeyInterop class is the "key," plus the fact that the Windows Forms Keys enumeration has the same integer values as the Win 32 virtual key codes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment