Skip to content

Instantly share code, notes, and snippets.

@erkantaylan
Created November 30, 2018 14:20
Show Gist options
  • Save erkantaylan/f6ec0bd0d5a58dd72836ba9a058251a2 to your computer and use it in GitHub Desktop.
Save erkantaylan/f6ec0bd0d5a58dd72836ba9a058251a2 to your computer and use it in GitHub Desktop.
converting Keys to Key and Key To Keys
public static class KeyExtensions
{
public static System.Windows.Input.Key ToKey(this System.Windows.Forms.Keys keys)
{
return System.Windows.Input.KeyInterop.KeyFromVirtualKey((int) keys);
}
public static System.Windows.Forms.Keys ToKeys(this System.Windows.Input.Key key)
{
return (System.Windows.Forms.Keys) System.Windows.Input.KeyInterop.VirtualKeyFromKey(key);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment