# Generic Keyboard Key Mapper Util Class I have encountered issue when developing platform universal C# code is that there are at least 3 different key maps. So I decided to make my own key type and map all other types from and to the values. I decided to use int values of those mappings instead of Enums or other tricks, to not have dependency on those assemblies. ## Supported from & to Types * [Win32 Virtual-Key Codes](https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes) * [System.Windows.Input.Key](https://docs.microsoft.com/en-us/dotnet/api/system.windows.input.key) * [System.Windows.Forms.Keys](https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.keys) * [DOM Javascript KeyboardEvent.key according MDN specs](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) ## Usage ```csharp // From Win32 public const VK_LCONTROL = 0xA2; var key = KeyboardKey.FromWin32(VK_LCONTROL); // From WPF Input.Key var key = KeyboardKey.FromWinInput((int) System.Windows.Input.Key.LeftCtrl); // From WinForm Forms.Key var key = KeyboardKey.FromWinForm((int) System.Windows.Forms.Keys.LControlKey); // From JS Key.key var key = KeyboardKey.FromJs("Control"); // Create an Key var key = KeyboardKey.LeftCtrl; // To Win32 Key var win32Key = key.ToWin32Key(); // To WPF Input.Key var wpfKey = (System.Windows.Input.Key) key.ToWinInputKey(); // To WinForm Key var winFormKey = (System.Windows.Forms.Keys) key.ToWinFormKey(); var jsKey = key.ToJavaScriptKey(); ``` ## License MIT License Copyright (c) 2021 Aurimas Niekis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.