|
using System; |
|
using System.Collections.Generic; |
|
|
|
public class KeyboardKey : IEquatable<KeyboardKey> |
|
{ |
|
public enum Keys |
|
{ |
|
None, |
|
Cancel, |
|
Backspace, |
|
Tab, |
|
Clear, |
|
Enter, |
|
Pause, |
|
CapsLock, |
|
Escape, |
|
Space, |
|
PageUp, |
|
PageDown, |
|
End, |
|
Home, |
|
ArrowLeft, |
|
ArrowUp, |
|
ArrowRight, |
|
ArrowDown, |
|
Select, |
|
Print, |
|
Execute, |
|
PrintScreen, |
|
Insert, |
|
Delete, |
|
Help, |
|
D0, |
|
D1, |
|
D2, |
|
D3, |
|
D4, |
|
D5, |
|
D6, |
|
D7, |
|
D8, |
|
D9, |
|
A, |
|
B, |
|
C, |
|
D, |
|
E, |
|
F, |
|
G, |
|
H, |
|
I, |
|
J, |
|
K, |
|
L, |
|
M, |
|
N, |
|
O, |
|
P, |
|
Q, |
|
R, |
|
S, |
|
T, |
|
U, |
|
V, |
|
W, |
|
X, |
|
Y, |
|
Z, |
|
Meta, |
|
LeftMeta, |
|
RightMeta, |
|
Apps, |
|
Sleep, |
|
NumPad0, |
|
NumPad1, |
|
NumPad2, |
|
NumPad3, |
|
NumPad4, |
|
NumPad5, |
|
NumPad6, |
|
NumPad7, |
|
NumPad8, |
|
NumPad9, |
|
Multiply, |
|
Add, |
|
Separator, |
|
Subtract, |
|
Decimal, |
|
Divide, |
|
F1, |
|
F2, |
|
F3, |
|
F4, |
|
F5, |
|
F6, |
|
F7, |
|
F8, |
|
F9, |
|
F10, |
|
F11, |
|
F12, |
|
F13, |
|
F14, |
|
F15, |
|
F16, |
|
F17, |
|
F18, |
|
F19, |
|
F20, |
|
F21, |
|
F22, |
|
F23, |
|
F24, |
|
NumLock, |
|
ScrollLock, |
|
Shift, |
|
LeftShift, |
|
RightShift, |
|
Control, |
|
LeftControl, |
|
RightControl, |
|
Alt, |
|
LeftAlt, |
|
RightAlt, |
|
BrowserBack, |
|
BrowserForward, |
|
BrowserRefresh, |
|
BrowserStop, |
|
BrowserSearch, |
|
BrowserFavorites, |
|
BrowserHome, |
|
VolumeMute, |
|
VolumeDown, |
|
VolumeUp, |
|
MediaNextTrack, |
|
MediaPreviousTrack, |
|
MediaStop, |
|
MediaPlayPause, |
|
LaunchMail, |
|
SelectMedia, |
|
LaunchApplication1, |
|
LaunchApplication2, |
|
SemiColon, |
|
Plus, |
|
Comma, |
|
Minus, |
|
Period, |
|
QuestionMark, |
|
OemTilde, |
|
OpenBracket, |
|
OemPipe, |
|
CloseBracket, |
|
Quote, |
|
Backslash, |
|
Play, |
|
Zoom, |
|
Unknown, |
|
} |
|
|
|
public enum KeySource |
|
{ |
|
Internal, |
|
Win32, |
|
WinInput, |
|
WinForm, |
|
JavaScript |
|
} |
|
|
|
public static readonly KeyboardKey None = new(Keys.None); |
|
public static readonly KeyboardKey Cancel = new(Keys.Cancel); |
|
public static readonly KeyboardKey Backspace = new(Keys.Backspace); |
|
public static readonly KeyboardKey Tab = new(Keys.Tab); |
|
public static readonly KeyboardKey Clear = new(Keys.Clear); |
|
public static readonly KeyboardKey Enter = new(Keys.Enter); |
|
public static readonly KeyboardKey Pause = new(Keys.Pause); |
|
public static readonly KeyboardKey CapsLock = new(Keys.CapsLock); |
|
public static readonly KeyboardKey Escape = new(Keys.Escape); |
|
public static readonly KeyboardKey Space = new(Keys.Space); |
|
public static readonly KeyboardKey PageUp = new(Keys.PageUp); |
|
public static readonly KeyboardKey PageDown = new(Keys.PageDown); |
|
public static readonly KeyboardKey End = new(Keys.End); |
|
public static readonly KeyboardKey Home = new(Keys.Home); |
|
public static readonly KeyboardKey ArrowLeft = new(Keys.ArrowLeft); |
|
public static readonly KeyboardKey ArrowUp = new(Keys.ArrowUp); |
|
public static readonly KeyboardKey ArrowRight = new(Keys.ArrowRight); |
|
public static readonly KeyboardKey ArrowDown = new(Keys.ArrowDown); |
|
public static readonly KeyboardKey Select = new(Keys.Select); |
|
public static readonly KeyboardKey Print = new(Keys.Print); |
|
public static readonly KeyboardKey Execute = new(Keys.Execute); |
|
public static readonly KeyboardKey PrintScreen = new(Keys.PrintScreen); |
|
public static readonly KeyboardKey Insert = new(Keys.Insert); |
|
public static readonly KeyboardKey Delete = new(Keys.Delete); |
|
public static readonly KeyboardKey Help = new(Keys.Help); |
|
public static readonly KeyboardKey D0 = new(Keys.D0); |
|
public static readonly KeyboardKey D1 = new(Keys.D1); |
|
public static readonly KeyboardKey D2 = new(Keys.D2); |
|
public static readonly KeyboardKey D3 = new(Keys.D3); |
|
public static readonly KeyboardKey D4 = new(Keys.D4); |
|
public static readonly KeyboardKey D5 = new(Keys.D5); |
|
public static readonly KeyboardKey D6 = new(Keys.D6); |
|
public static readonly KeyboardKey D7 = new(Keys.D7); |
|
public static readonly KeyboardKey D8 = new(Keys.D8); |
|
public static readonly KeyboardKey D9 = new(Keys.D9); |
|
public static readonly KeyboardKey A = new(Keys.A); |
|
public static readonly KeyboardKey B = new(Keys.B); |
|
public static readonly KeyboardKey C = new(Keys.C); |
|
public static readonly KeyboardKey D = new(Keys.D); |
|
public static readonly KeyboardKey E = new(Keys.E); |
|
public static readonly KeyboardKey F = new(Keys.F); |
|
public static readonly KeyboardKey G = new(Keys.G); |
|
public static readonly KeyboardKey H = new(Keys.H); |
|
public static readonly KeyboardKey I = new(Keys.I); |
|
public static readonly KeyboardKey J = new(Keys.J); |
|
public static readonly KeyboardKey K = new(Keys.K); |
|
public static readonly KeyboardKey L = new(Keys.L); |
|
public static readonly KeyboardKey M = new(Keys.M); |
|
public static readonly KeyboardKey N = new(Keys.N); |
|
public static readonly KeyboardKey O = new(Keys.O); |
|
public static readonly KeyboardKey P = new(Keys.P); |
|
public static readonly KeyboardKey Q = new(Keys.Q); |
|
public static readonly KeyboardKey R = new(Keys.R); |
|
public static readonly KeyboardKey S = new(Keys.S); |
|
public static readonly KeyboardKey T = new(Keys.T); |
|
public static readonly KeyboardKey U = new(Keys.U); |
|
public static readonly KeyboardKey V = new(Keys.V); |
|
public static readonly KeyboardKey W = new(Keys.W); |
|
public static readonly KeyboardKey X = new(Keys.X); |
|
public static readonly KeyboardKey Y = new(Keys.Y); |
|
public static readonly KeyboardKey Z = new(Keys.Z); |
|
public static readonly KeyboardKey Meta = new(Keys.Meta); |
|
public static readonly KeyboardKey LeftMeta = new(Keys.LeftMeta); |
|
public static readonly KeyboardKey RightMeta = new(Keys.RightMeta); |
|
public static readonly KeyboardKey Apps = new(Keys.Apps); |
|
public static readonly KeyboardKey Sleep = new(Keys.Sleep); |
|
public static readonly KeyboardKey NumPad0 = new(Keys.NumPad0); |
|
public static readonly KeyboardKey NumPad1 = new(Keys.NumPad1); |
|
public static readonly KeyboardKey NumPad2 = new(Keys.NumPad2); |
|
public static readonly KeyboardKey NumPad3 = new(Keys.NumPad3); |
|
public static readonly KeyboardKey NumPad4 = new(Keys.NumPad4); |
|
public static readonly KeyboardKey NumPad5 = new(Keys.NumPad5); |
|
public static readonly KeyboardKey NumPad6 = new(Keys.NumPad6); |
|
public static readonly KeyboardKey NumPad7 = new(Keys.NumPad7); |
|
public static readonly KeyboardKey NumPad8 = new(Keys.NumPad8); |
|
public static readonly KeyboardKey NumPad9 = new(Keys.NumPad9); |
|
public static readonly KeyboardKey Multiply = new(Keys.Multiply); |
|
public static readonly KeyboardKey Add = new(Keys.Add); |
|
public static readonly KeyboardKey Separator = new(Keys.Separator); |
|
public static readonly KeyboardKey Subtract = new(Keys.Subtract); |
|
public static readonly KeyboardKey Decimal = new(Keys.Decimal); |
|
public static readonly KeyboardKey Divide = new(Keys.Divide); |
|
public static readonly KeyboardKey F1 = new(Keys.F1); |
|
public static readonly KeyboardKey F2 = new(Keys.F2); |
|
public static readonly KeyboardKey F3 = new(Keys.F3); |
|
public static readonly KeyboardKey F4 = new(Keys.F4); |
|
public static readonly KeyboardKey F5 = new(Keys.F5); |
|
public static readonly KeyboardKey F6 = new(Keys.F6); |
|
public static readonly KeyboardKey F7 = new(Keys.F7); |
|
public static readonly KeyboardKey F8 = new(Keys.F8); |
|
public static readonly KeyboardKey F9 = new(Keys.F9); |
|
public static readonly KeyboardKey F10 = new(Keys.F10); |
|
public static readonly KeyboardKey F11 = new(Keys.F11); |
|
public static readonly KeyboardKey F12 = new(Keys.F12); |
|
public static readonly KeyboardKey F13 = new(Keys.F13); |
|
public static readonly KeyboardKey F14 = new(Keys.F14); |
|
public static readonly KeyboardKey F15 = new(Keys.F15); |
|
public static readonly KeyboardKey F16 = new(Keys.F16); |
|
public static readonly KeyboardKey F17 = new(Keys.F17); |
|
public static readonly KeyboardKey F18 = new(Keys.F18); |
|
public static readonly KeyboardKey F19 = new(Keys.F19); |
|
public static readonly KeyboardKey F20 = new(Keys.F20); |
|
public static readonly KeyboardKey F21 = new(Keys.F21); |
|
public static readonly KeyboardKey F22 = new(Keys.F22); |
|
public static readonly KeyboardKey F23 = new(Keys.F23); |
|
public static readonly KeyboardKey F24 = new(Keys.F24); |
|
public static readonly KeyboardKey NumLock = new(Keys.NumLock); |
|
public static readonly KeyboardKey ScrollLock = new(Keys.ScrollLock); |
|
public static readonly KeyboardKey Shift = new(Keys.Shift); |
|
public static readonly KeyboardKey LeftShift = new(Keys.LeftShift); |
|
public static readonly KeyboardKey RightShift = new(Keys.RightShift); |
|
public static readonly KeyboardKey Control = new(Keys.Control); |
|
public static readonly KeyboardKey LeftControl = new(Keys.LeftControl); |
|
public static readonly KeyboardKey RightControl = new(Keys.RightControl); |
|
public static readonly KeyboardKey Alt = new(Keys.Alt); |
|
public static readonly KeyboardKey LeftAlt = new(Keys.LeftAlt); |
|
public static readonly KeyboardKey RightAlt = new(Keys.RightAlt); |
|
public static readonly KeyboardKey BrowserBack = new(Keys.BrowserBack); |
|
public static readonly KeyboardKey BrowserForward = new(Keys.BrowserForward); |
|
public static readonly KeyboardKey BrowserRefresh = new(Keys.BrowserRefresh); |
|
public static readonly KeyboardKey BrowserStop = new(Keys.BrowserStop); |
|
public static readonly KeyboardKey BrowserSearch = new(Keys.BrowserSearch); |
|
public static readonly KeyboardKey BrowserFavorites = new(Keys.BrowserFavorites); |
|
public static readonly KeyboardKey BrowserHome = new(Keys.BrowserHome); |
|
public static readonly KeyboardKey VolumeMute = new(Keys.VolumeMute); |
|
public static readonly KeyboardKey VolumeDown = new(Keys.VolumeDown); |
|
public static readonly KeyboardKey VolumeUp = new(Keys.VolumeUp); |
|
public static readonly KeyboardKey MediaNextTrack = new(Keys.MediaNextTrack); |
|
public static readonly KeyboardKey MediaPreviousTrack = new(Keys.MediaPreviousTrack); |
|
public static readonly KeyboardKey MediaStop = new(Keys.MediaStop); |
|
public static readonly KeyboardKey MediaPlayPause = new(Keys.MediaPlayPause); |
|
public static readonly KeyboardKey LaunchMail = new(Keys.LaunchMail); |
|
public static readonly KeyboardKey SelectMedia = new(Keys.SelectMedia); |
|
public static readonly KeyboardKey LaunchApplication1 = new(Keys.LaunchApplication1); |
|
public static readonly KeyboardKey LaunchApplication2 = new(Keys.LaunchApplication2); |
|
public static readonly KeyboardKey SemiColon = new(Keys.SemiColon); |
|
public static readonly KeyboardKey Plus = new(Keys.Plus); |
|
public static readonly KeyboardKey Comma = new(Keys.Comma); |
|
public static readonly KeyboardKey Minus = new(Keys.Minus); |
|
public static readonly KeyboardKey Period = new(Keys.Period); |
|
public static readonly KeyboardKey QuestionMark = new(Keys.QuestionMark); |
|
public static readonly KeyboardKey OemTilde = new(Keys.OemTilde); |
|
public static readonly KeyboardKey OpenBracket = new(Keys.OpenBracket); |
|
public static readonly KeyboardKey OemPipe = new(Keys.OemPipe); |
|
public static readonly KeyboardKey CloseBracket = new(Keys.CloseBracket); |
|
public static readonly KeyboardKey Quote = new(Keys.Quote); |
|
public static readonly KeyboardKey Backslash = new(Keys.Backslash); |
|
public static readonly KeyboardKey Play = new(Keys.Play); |
|
public static readonly KeyboardKey Zoom = new(Keys.Zoom); |
|
|
|
private static readonly Dictionary<Keys, int[]> KeyToValues = new() |
|
{ |
|
{Keys.None, new[] {0, 0, 0x00}}, |
|
{Keys.Cancel, new[] {1, 3, 0x03}}, |
|
{Keys.Backspace, new[] {2, 8, 0x08}}, |
|
{Keys.Tab, new[] {3, 9, 0x09}}, |
|
{Keys.Clear, new[] {5, 12, 0x0C}}, |
|
{Keys.Enter, new[] {6, 13, 0x0D}}, |
|
{Keys.Pause, new[] {7, 19, 0x13}}, |
|
{Keys.CapsLock, new[] {8, 20, 0x14}}, |
|
{Keys.Escape, new[] {13, 27, 0x1B}}, |
|
{Keys.Space, new[] {18, 32, 0x20}}, |
|
{Keys.PageUp, new[] {19, 33, 0x21}}, |
|
{Keys.PageDown, new[] {20, 34, 0x22}}, |
|
{Keys.End, new[] {21, 35, 0x23}}, |
|
{Keys.Home, new[] {22, 36, 0x24}}, |
|
{Keys.ArrowLeft, new[] {23, 37, 0x25}}, |
|
{Keys.ArrowUp, new[] {24, 38, 0x26}}, |
|
{Keys.ArrowRight, new[] {25, 39, 0x27}}, |
|
{Keys.ArrowDown, new[] {26, 40, 0x28}}, |
|
{Keys.Select, new[] {27, 41, 0x29}}, |
|
{Keys.Print, new[] {28, 42, 0x2A}}, |
|
{Keys.Execute, new[] {29, 43, 0x2B}}, |
|
{Keys.PrintScreen, new[] {30, 44, 0x2C}}, |
|
{Keys.Insert, new[] {31, 45, 0x2D}}, |
|
{Keys.Delete, new[] {32, 46, 0x2E}}, |
|
{Keys.Help, new[] {33, 47, 0x2F}}, |
|
{Keys.D0, new[] {34, 48, 0x30}}, |
|
{Keys.D1, new[] {35, 49, 0x31}}, |
|
{Keys.D2, new[] {36, 50, 0x32}}, |
|
{Keys.D3, new[] {37, 51, 0x33}}, |
|
{Keys.D4, new[] {38, 52, 0x34}}, |
|
{Keys.D5, new[] {39, 53, 0x35}}, |
|
{Keys.D6, new[] {40, 54, 0x36}}, |
|
{Keys.D7, new[] {41, 55, 0x37}}, |
|
{Keys.D8, new[] {42, 56, 0x38}}, |
|
{Keys.D9, new[] {43, 57, 0x39}}, |
|
{Keys.A, new[] {44, 65, 0x41}}, |
|
{Keys.B, new[] {45, 66, 0x42}}, |
|
{Keys.C, new[] {46, 67, 0x43}}, |
|
{Keys.D, new[] {47, 68, 0x44}}, |
|
{Keys.E, new[] {48, 69, 0x45}}, |
|
{Keys.F, new[] {49, 70, 0x46}}, |
|
{Keys.G, new[] {50, 71, 0x47}}, |
|
{Keys.H, new[] {51, 72, 0x48}}, |
|
{Keys.I, new[] {52, 73, 0x49}}, |
|
{Keys.J, new[] {53, 74, 0x4A}}, |
|
{Keys.K, new[] {54, 75, 0x4B}}, |
|
{Keys.L, new[] {55, 76, 0x4C}}, |
|
{Keys.M, new[] {56, 77, 0x4D}}, |
|
{Keys.N, new[] {57, 78, 0x4E}}, |
|
{Keys.O, new[] {58, 79, 0x4F}}, |
|
{Keys.P, new[] {59, 80, 0x50}}, |
|
{Keys.Q, new[] {60, 81, 0x51}}, |
|
{Keys.R, new[] {61, 82, 0x52}}, |
|
{Keys.S, new[] {62, 83, 0x53}}, |
|
{Keys.T, new[] {63, 84, 0x54}}, |
|
{Keys.U, new[] {64, 85, 0x55}}, |
|
{Keys.V, new[] {65, 86, 0x56}}, |
|
{Keys.W, new[] {66, 87, 0x57}}, |
|
{Keys.X, new[] {67, 88, 0x58}}, |
|
{Keys.Y, new[] {68, 89, 0x59}}, |
|
{Keys.Z, new[] {69, 90, 0x5A}}, |
|
{Keys.Meta, new[] {70, 91, 0x5B}}, |
|
{Keys.LeftMeta, new[] {70, 91, 0x5B}}, |
|
{Keys.RightMeta, new[] {71, 92, 0x5C}}, |
|
{Keys.Apps, new[] {72, 93, 0x5D}}, |
|
{Keys.Sleep, new[] {73, 95, 0x5F}}, |
|
{Keys.NumPad0, new[] {74, 96, 0x60}}, |
|
{Keys.NumPad1, new[] {75, 97, 0x61}}, |
|
{Keys.NumPad2, new[] {76, 98, 0x62}}, |
|
{Keys.NumPad3, new[] {77, 99, 0x63}}, |
|
{Keys.NumPad4, new[] {78, 100, 0x64}}, |
|
{Keys.NumPad5, new[] {79, 101, 0x65}}, |
|
{Keys.NumPad6, new[] {80, 102, 0x66}}, |
|
{Keys.NumPad7, new[] {81, 103, 0x67}}, |
|
{Keys.NumPad8, new[] {82, 104, 0x68}}, |
|
{Keys.NumPad9, new[] {83, 105, 0x69}}, |
|
{Keys.Multiply, new[] {84, 106, 0x6A}}, |
|
{Keys.Add, new[] {85, 107, 0x6B}}, |
|
{Keys.Separator, new[] {86, 108, 0x6C}}, |
|
{Keys.Subtract, new[] {87, 109, 0x6D}}, |
|
{Keys.Decimal, new[] {88, 110, 0x6E}}, |
|
{Keys.Divide, new[] {89, 111, 0x6F}}, |
|
{Keys.F1, new[] {90, 112, 0x70}}, |
|
{Keys.F2, new[] {91, 113, 0x71}}, |
|
{Keys.F3, new[] {92, 114, 0x72}}, |
|
{Keys.F4, new[] {93, 115, 0x73}}, |
|
{Keys.F5, new[] {94, 116, 0x74}}, |
|
{Keys.F6, new[] {95, 117, 0x75}}, |
|
{Keys.F7, new[] {96, 118, 0x76}}, |
|
{Keys.F8, new[] {97, 119, 0x77}}, |
|
{Keys.F9, new[] {98, 120, 0x78}}, |
|
{Keys.F10, new[] {99, 121, 0x79}}, |
|
{Keys.F11, new[] {100, 122, 0x7A}}, |
|
{Keys.F12, new[] {101, 123, 0x7B}}, |
|
{Keys.F13, new[] {102, 124, 0x7C}}, |
|
{Keys.F14, new[] {103, 125, 0x7D}}, |
|
{Keys.F15, new[] {104, 126, 0x7E}}, |
|
{Keys.F16, new[] {105, 127, 0x7F}}, |
|
{Keys.F17, new[] {106, 128, 0x80}}, |
|
{Keys.F18, new[] {107, 129, 0x81}}, |
|
{Keys.F19, new[] {108, 130, 0x82}}, |
|
{Keys.F20, new[] {109, 131, 0x83}}, |
|
{Keys.F21, new[] {110, 132, 0x84}}, |
|
{Keys.F22, new[] {111, 133, 0x85}}, |
|
{Keys.F23, new[] {112, 134, 0x86}}, |
|
{Keys.F24, new[] {113, 135, 0x87}}, |
|
{Keys.NumLock, new[] {114, 144, 0x90}}, |
|
{Keys.ScrollLock, new[] {115, 145, 0x91}}, |
|
{Keys.Shift, new[] {116, 160, 0xA0}}, |
|
{Keys.LeftShift, new[] {116, 160, 0xA0}}, |
|
{Keys.RightShift, new[] {117, 161, 0xA1}}, |
|
{Keys.Control, new[] {118, 162, 0xA2}}, |
|
{Keys.LeftControl, new[] {118, 162, 0xA2}}, |
|
{Keys.RightControl, new[] {119, 163, 0xA3}}, |
|
{Keys.Alt, new[] {120, 164, 0xA4}}, |
|
{Keys.LeftAlt, new[] {120, 164, 0xA4}}, |
|
{Keys.RightAlt, new[] {121, 165, 0xA5}}, |
|
{Keys.BrowserBack, new[] {122, 166, 0xA6}}, |
|
{Keys.BrowserForward, new[] {123, 167, 0xA7}}, |
|
{Keys.BrowserRefresh, new[] {124, 168, 0xA8}}, |
|
{Keys.BrowserStop, new[] {125, 169, 0xA9}}, |
|
{Keys.BrowserSearch, new[] {126, 170, 0xAA}}, |
|
{Keys.BrowserFavorites, new[] {127, 171, 0xAB}}, |
|
{Keys.BrowserHome, new[] {128, 172, 0xAC}}, |
|
{Keys.VolumeMute, new[] {129, 173, 0xAD}}, |
|
{Keys.VolumeDown, new[] {130, 174, 0xAE}}, |
|
{Keys.VolumeUp, new[] {131, 175, 0xAF}}, |
|
{Keys.MediaNextTrack, new[] {132, 176, 0xB0}}, |
|
{Keys.MediaPreviousTrack, new[] {133, 177, 0xB1}}, |
|
{Keys.MediaStop, new[] {134, 178, 0xB2}}, |
|
{Keys.MediaPlayPause, new[] {135, 179, 0xB3}}, |
|
{Keys.LaunchMail, new[] {136, 180, 0xB4}}, |
|
{Keys.SelectMedia, new[] {137, 181, 0xB5}}, |
|
{Keys.LaunchApplication1, new[] {138, 182, 0xB6}}, |
|
{Keys.LaunchApplication2, new[] {139, 183, 0xB7}}, |
|
{Keys.SemiColon, new[] {140, 186, 0xBA}}, |
|
{Keys.Plus, new[] {141, 187, 0xBB}}, |
|
{Keys.Comma, new[] {142, 188, 0xBC}}, |
|
{Keys.Minus, new[] {143, 189, 0xBD}}, |
|
{Keys.Period, new[] {144, 190, 0xBE}}, |
|
{Keys.QuestionMark, new[] {145, 191, 0xBF}}, |
|
{Keys.OemTilde, new[] {146, 192, 0xC0}}, |
|
{Keys.OpenBracket, new[] {149, 219, 0xDB}}, |
|
{Keys.OemPipe, new[] {150, 220, 0xDC}}, |
|
{Keys.CloseBracket, new[] {151, 221, 0xDD}}, |
|
{Keys.Quote, new[] {152, 222, 0xDE}}, |
|
{Keys.Backslash, new[] {154, 226, 0xE2}}, |
|
{Keys.Play, new[] {167, 250, 0xFA}}, |
|
{Keys.Zoom, new[] {168, 251, 0xFB}} |
|
}; |
|
|
|
public static KeyboardKey Unknown = new(Keys.Unknown); |
|
|
|
private static readonly Dictionary<Keys, string> KeyToJsValues = new() |
|
{ |
|
{Keys.None, "Unidentified"}, |
|
{Keys.Cancel, "Cancel"}, |
|
{Keys.Backspace, "Backspace"}, |
|
{Keys.Tab, "Tab"}, |
|
{Keys.Clear, "Clear"}, |
|
{Keys.Enter, "Enter"}, |
|
{Keys.Pause, "Pause"}, |
|
{Keys.CapsLock, "CapsLock"}, |
|
{Keys.Escape, "Escape"}, |
|
{Keys.Space, " "}, |
|
{Keys.PageUp, "PageUp"}, |
|
{Keys.PageDown, "PageDown"}, |
|
{Keys.End, "End"}, |
|
{Keys.Home, "Home"}, |
|
{Keys.ArrowLeft, "ArrowLeft"}, |
|
{Keys.ArrowUp, "ArrowUp"}, |
|
{Keys.ArrowRight, "ArrowRight"}, |
|
{Keys.ArrowDown, "ArrowDown"}, |
|
{Keys.Select, "Select"}, |
|
{Keys.Print, "PrintScreen"}, |
|
{Keys.Execute, "Execute"}, |
|
{Keys.PrintScreen, "PrintScreen"}, |
|
{Keys.Insert, "Insert"}, |
|
{Keys.Delete, "Delete"}, |
|
{Keys.Help, "Help"}, |
|
{Keys.D0, "0"}, |
|
{Keys.D1, "1"}, |
|
{Keys.D2, "2"}, |
|
{Keys.D3, "3"}, |
|
{Keys.D4, "4"}, |
|
{Keys.D5, "5"}, |
|
{Keys.D6, "6"}, |
|
{Keys.D7, "7"}, |
|
{Keys.D8, "8"}, |
|
{Keys.D9, "9"}, |
|
{Keys.A, "a"}, |
|
{Keys.B, "b"}, |
|
{Keys.C, "c"}, |
|
{Keys.D, "d"}, |
|
{Keys.E, "e"}, |
|
{Keys.F, "f"}, |
|
{Keys.G, "g"}, |
|
{Keys.H, "h"}, |
|
{Keys.I, "i"}, |
|
{Keys.J, "j"}, |
|
{Keys.K, "k"}, |
|
{Keys.L, "l"}, |
|
{Keys.M, "m"}, |
|
{Keys.N, "n"}, |
|
{Keys.O, "o"}, |
|
{Keys.P, "p"}, |
|
{Keys.Q, "q"}, |
|
{Keys.R, "r"}, |
|
{Keys.S, "s"}, |
|
{Keys.T, "t"}, |
|
{Keys.U, "u"}, |
|
{Keys.V, "v"}, |
|
{Keys.W, "w"}, |
|
{Keys.X, "x"}, |
|
{Keys.Y, "y"}, |
|
{Keys.Z, "z"}, |
|
{Keys.Meta, "Meta"}, |
|
{Keys.LeftMeta, "Meta"}, |
|
{Keys.RightMeta, "Meta"}, |
|
{Keys.Apps, "AppSwitch"}, |
|
{Keys.Sleep, "Standby"}, |
|
{Keys.NumPad0, "0"}, |
|
{Keys.NumPad1, "1"}, |
|
{Keys.NumPad2, "2"}, |
|
{Keys.NumPad3, "3"}, |
|
{Keys.NumPad4, "4"}, |
|
{Keys.NumPad5, "5"}, |
|
{Keys.NumPad6, "6"}, |
|
{Keys.NumPad7, "7"}, |
|
{Keys.NumPad8, "8"}, |
|
{Keys.NumPad9, "9"}, |
|
{Keys.Multiply, "Multiply"}, |
|
{Keys.Add, "Add"}, |
|
{Keys.Separator, "Separator"}, |
|
{Keys.Subtract, "Subtract"}, |
|
{Keys.Decimal, "Decimal"}, |
|
{Keys.Divide, "Divide"}, |
|
{Keys.F1, "F1"}, |
|
{Keys.F2, "F2"}, |
|
{Keys.F3, "F3"}, |
|
{Keys.F4, "F4"}, |
|
{Keys.F5, "F5"}, |
|
{Keys.F6, "F6"}, |
|
{Keys.F7, "F7"}, |
|
{Keys.F8, "F8"}, |
|
{Keys.F9, "F9"}, |
|
{Keys.F10, "F10"}, |
|
{Keys.F11, "F11"}, |
|
{Keys.F12, "F12"}, |
|
{Keys.F13, "F13"}, |
|
{Keys.F14, "F14"}, |
|
{Keys.F15, "F15"}, |
|
{Keys.F16, "F16"}, |
|
{Keys.F17, "F17"}, |
|
{Keys.F18, "F18"}, |
|
{Keys.F19, "F19"}, |
|
{Keys.F20, "F20"}, |
|
{Keys.F21, "Unidentified"}, |
|
{Keys.F22, "Unidentified"}, |
|
{Keys.F23, "Unidentified"}, |
|
{Keys.F24, "Unidentified"}, |
|
{Keys.NumLock, "NumLock"}, |
|
{Keys.ScrollLock, "ScrollLock"}, |
|
{Keys.Shift, "Shift"}, |
|
{Keys.LeftShift, "Shift"}, |
|
{Keys.RightShift, "Shift"}, |
|
{Keys.Control, "Control"}, |
|
{Keys.LeftControl, "Control"}, |
|
{Keys.RightControl, "Control"}, |
|
{Keys.Alt, "Alt"}, |
|
{Keys.LeftAlt, "Alt"}, |
|
{Keys.RightAlt, "Alt"}, |
|
{Keys.BrowserBack, "BrowserBack"}, |
|
{Keys.BrowserForward, "BrowserForward"}, |
|
{Keys.BrowserRefresh, "BrowserRefresh"}, |
|
{Keys.BrowserStop, "BrowserStop"}, |
|
{Keys.BrowserSearch, "BrowserSearch"}, |
|
{Keys.BrowserFavorites, "BrowserFavorites"}, |
|
{Keys.BrowserHome, "BrowserHome"}, |
|
{Keys.VolumeMute, "AudioVolumeMute"}, |
|
{Keys.VolumeDown, "AudioVolumeDown"}, |
|
{Keys.VolumeUp, "AudioVolumeUp"}, |
|
{Keys.MediaNextTrack, "MediaTrackNext"}, |
|
{Keys.MediaPreviousTrack, "MediaTrackPrevious"}, |
|
{Keys.MediaStop, "MediaStop"}, |
|
{Keys.MediaPlayPause, "MediaPlayPause"}, |
|
{Keys.LaunchMail, "LaunchMail"}, |
|
{Keys.SelectMedia, "LaunchMediaPlayer"}, |
|
{Keys.LaunchApplication1, "LaunchApplication1"}, |
|
{Keys.LaunchApplication2, "LaunchApplication2"}, |
|
{Keys.SemiColon, ";"}, |
|
{Keys.Plus, "+"}, |
|
{Keys.Comma, ","}, |
|
{Keys.Minus, "-"}, |
|
{Keys.Period, "."}, |
|
{Keys.QuestionMark, "?"}, |
|
{Keys.OemTilde, "~"}, |
|
{Keys.OpenBracket, "["}, |
|
{Keys.OemPipe, "|"}, |
|
{Keys.CloseBracket, "]"}, |
|
{Keys.Quote, "'"}, |
|
{Keys.Backslash, "\\"}, |
|
{Keys.Play, "Play"}, |
|
{Keys.Zoom, "ZoomToggle"} |
|
}; |
|
|
|
protected static Dictionary<string, Keys> JsToKeys = new() |
|
{ |
|
{"Unidentified", Keys.None}, |
|
{"Cancel", Keys.Cancel}, |
|
{"Backspace", Keys.Backspace}, |
|
{"Tab", Keys.Tab}, |
|
{"Clear", Keys.Clear}, |
|
{"Enter", Keys.Enter}, |
|
{"Pause", Keys.Pause}, |
|
{"CapsLock", Keys.CapsLock}, |
|
{"Escape", Keys.Escape}, |
|
{" ", Keys.Space}, |
|
{"PageUp", Keys.PageUp}, |
|
{"PageDown", Keys.PageDown}, |
|
{"End", Keys.End}, |
|
{"Home", Keys.Home}, |
|
{"ArrowLeft", Keys.ArrowLeft}, |
|
{"ArrowUp", Keys.ArrowUp}, |
|
{"ArrowRight", Keys.ArrowRight}, |
|
{"ArrowDown", Keys.ArrowDown}, |
|
{"Select", Keys.Select}, |
|
{"PrintScreen", Keys.Print}, |
|
{"Execute", Keys.Execute}, |
|
{"PrintScreen", Keys.PrintScreen}, |
|
{"Insert", Keys.Insert}, |
|
{"Delete", Keys.Delete}, |
|
{"Help", Keys.Help}, |
|
{"0", Keys.D0}, |
|
{"1", Keys.D1}, |
|
{"2", Keys.D2}, |
|
{"3", Keys.D3}, |
|
{"4", Keys.D4}, |
|
{"5", Keys.D5}, |
|
{"6", Keys.D6}, |
|
{"7", Keys.D7}, |
|
{"8", Keys.D8}, |
|
{"9", Keys.D9}, |
|
{"a", Keys.A}, |
|
{"b", Keys.B}, |
|
{"c", Keys.C}, |
|
{"d", Keys.D}, |
|
{"e", Keys.E}, |
|
{"f", Keys.F}, |
|
{"g", Keys.G}, |
|
{"h", Keys.H}, |
|
{"i", Keys.I}, |
|
{"j", Keys.J}, |
|
{"k", Keys.K}, |
|
{"l", Keys.L}, |
|
{"m", Keys.M}, |
|
{"n", Keys.N}, |
|
{"o", Keys.O}, |
|
{"p", Keys.P}, |
|
{"q", Keys.Q}, |
|
{"r", Keys.R}, |
|
{"s", Keys.S}, |
|
{"t", Keys.T}, |
|
{"u", Keys.U}, |
|
{"v", Keys.V}, |
|
{"w", Keys.W}, |
|
{"x", Keys.X}, |
|
{"y", Keys.Y}, |
|
{"z", Keys.Z}, |
|
{"Meta", Keys.Meta}, |
|
{"AppSwitch", Keys.Apps}, |
|
{"Standby", Keys.Sleep}, |
|
{"0", Keys.NumPad0}, |
|
{"1", Keys.NumPad1}, |
|
{"2", Keys.NumPad2}, |
|
{"3", Keys.NumPad3}, |
|
{"4", Keys.NumPad4}, |
|
{"5", Keys.NumPad5}, |
|
{"6", Keys.NumPad6}, |
|
{"7", Keys.NumPad7}, |
|
{"8", Keys.NumPad8}, |
|
{"9", Keys.NumPad9}, |
|
{"Multiply", Keys.Multiply}, |
|
{"Add", Keys.Add}, |
|
{"Separator", Keys.Separator}, |
|
{"Subtract", Keys.Subtract}, |
|
{"Decimal", Keys.Decimal}, |
|
{"Divide", Keys.Divide}, |
|
{"F1", Keys.F1}, |
|
{"F2", Keys.F2}, |
|
{"F3", Keys.F3}, |
|
{"F4", Keys.F4}, |
|
{"F5", Keys.F5}, |
|
{"F6", Keys.F6}, |
|
{"F7", Keys.F7}, |
|
{"F8", Keys.F8}, |
|
{"F9", Keys.F9}, |
|
{"F10", Keys.F10}, |
|
{"F11", Keys.F11}, |
|
{"F12", Keys.F12}, |
|
{"F13", Keys.F13}, |
|
{"F14", Keys.F14}, |
|
{"F15", Keys.F15}, |
|
{"F16", Keys.F16}, |
|
{"F17", Keys.F17}, |
|
{"F18", Keys.F18}, |
|
{"F19", Keys.F19}, |
|
{"F20", Keys.F20}, |
|
{"Unidentified", Keys.F21}, |
|
{"Unidentified", Keys.F22}, |
|
{"Unidentified", Keys.F23}, |
|
{"Unidentified", Keys.F24}, |
|
{"NumLock", Keys.NumLock}, |
|
{"ScrollLock", Keys.ScrollLock}, |
|
{"Shift", Keys.Shift}, |
|
{"Control", Keys.Control}, |
|
{"Alt", Keys.Alt}, |
|
{"BrowserBack", Keys.BrowserBack}, |
|
{"BrowserForward", Keys.BrowserForward}, |
|
{"BrowserRefresh", Keys.BrowserRefresh}, |
|
{"BrowserStop", Keys.BrowserStop}, |
|
{"BrowserSearch", Keys.BrowserSearch}, |
|
{"BrowserFavorites", Keys.BrowserFavorites}, |
|
{"BrowserHome", Keys.BrowserHome}, |
|
{"AudioVolumeMute", Keys.VolumeMute}, |
|
{"AudioVolumeDown", Keys.VolumeDown}, |
|
{"AudioVolumeUp", Keys.VolumeUp}, |
|
{"MediaTrackNext", Keys.MediaNextTrack}, |
|
{"MediaTrackPrevious", Keys.MediaPreviousTrack}, |
|
{"MediaStop", Keys.MediaStop}, |
|
{"MediaPlayPause", Keys.MediaPlayPause}, |
|
{"LaunchMail", Keys.LaunchMail}, |
|
{"LaunchMediaPlayer", Keys.SelectMedia}, |
|
{"LaunchApplication1", Keys.LaunchApplication1}, |
|
{"LaunchApplication2", Keys.LaunchApplication2}, |
|
{";", Keys.SemiColon}, |
|
{"+", Keys.Plus}, |
|
{",", Keys.Comma}, |
|
{"-", Keys.Minus}, |
|
{".", Keys.Period}, |
|
{"?", Keys.QuestionMark}, |
|
{"~", Keys.OemTilde}, |
|
{"[", Keys.OpenBracket}, |
|
{"|", Keys.OemPipe}, |
|
{"]", Keys.CloseBracket}, |
|
{"'", Keys.Quote}, |
|
{"\\", Keys.Backslash}, |
|
{"Play", Keys.Play}, |
|
{"ZoomToggle", Keys.Zoom} |
|
}; |
|
|
|
private static readonly Dictionary<int, Keys> Win32ToKey = new() |
|
{ |
|
{0x00, Keys.None}, |
|
{0x03, Keys.Cancel}, |
|
{0x08, Keys.Backspace}, |
|
{0x09, Keys.Tab}, |
|
{0x0C, Keys.Clear}, |
|
{0x0D, Keys.Enter}, |
|
{0x0D, Keys.Enter}, |
|
{0x13, Keys.Pause}, |
|
{0x14, Keys.CapsLock}, |
|
{0x14, Keys.CapsLock}, |
|
{0x1B, Keys.Escape}, |
|
{0x20, Keys.Space}, |
|
{0x21, Keys.PageUp}, |
|
{0x21, Keys.PageUp}, |
|
{0x22, Keys.PageDown}, |
|
{0x22, Keys.PageDown}, |
|
{0x23, Keys.End}, |
|
{0x24, Keys.Home}, |
|
{0x25, Keys.ArrowLeft}, |
|
{0x26, Keys.ArrowUp}, |
|
{0x27, Keys.ArrowRight}, |
|
{0x28, Keys.ArrowDown}, |
|
{0x29, Keys.Select}, |
|
{0x2A, Keys.Print}, |
|
{0x2B, Keys.Execute}, |
|
{0x2C, Keys.PrintScreen}, |
|
{0x2C, Keys.PrintScreen}, |
|
{0x2D, Keys.Insert}, |
|
{0x2E, Keys.Delete}, |
|
{0x2F, Keys.Help}, |
|
{0x30, Keys.D0}, |
|
{0x31, Keys.D1}, |
|
{0x32, Keys.D2}, |
|
{0x33, Keys.D3}, |
|
{0x34, Keys.D4}, |
|
{0x35, Keys.D5}, |
|
{0x36, Keys.D6}, |
|
{0x37, Keys.D7}, |
|
{0x38, Keys.D8}, |
|
{0x39, Keys.D9}, |
|
{0x41, Keys.A}, |
|
{0x42, Keys.B}, |
|
{0x43, Keys.C}, |
|
{0x44, Keys.D}, |
|
{0x45, Keys.E}, |
|
{0x46, Keys.F}, |
|
{0x47, Keys.G}, |
|
{0x48, Keys.H}, |
|
{0x49, Keys.I}, |
|
{0x4A, Keys.J}, |
|
{0x4B, Keys.K}, |
|
{0x4C, Keys.L}, |
|
{0x4D, Keys.M}, |
|
{0x4E, Keys.N}, |
|
{0x4F, Keys.O}, |
|
{0x50, Keys.P}, |
|
{0x51, Keys.Q}, |
|
{0x52, Keys.R}, |
|
{0x53, Keys.S}, |
|
{0x54, Keys.T}, |
|
{0x55, Keys.U}, |
|
{0x56, Keys.V}, |
|
{0x57, Keys.W}, |
|
{0x58, Keys.X}, |
|
{0x59, Keys.Y}, |
|
{0x5A, Keys.Z}, |
|
{0x5B, Keys.LeftMeta}, |
|
{0x5C, Keys.RightMeta}, |
|
{0x5D, Keys.Apps}, |
|
{0x5F, Keys.Sleep}, |
|
{0x60, Keys.NumPad0}, |
|
{0x61, Keys.NumPad1}, |
|
{0x62, Keys.NumPad2}, |
|
{0x63, Keys.NumPad3}, |
|
{0x64, Keys.NumPad4}, |
|
{0x65, Keys.NumPad5}, |
|
{0x66, Keys.NumPad6}, |
|
{0x67, Keys.NumPad7}, |
|
{0x68, Keys.NumPad8}, |
|
{0x69, Keys.NumPad9}, |
|
{0x6A, Keys.Multiply}, |
|
{0x6B, Keys.Add}, |
|
{0x6C, Keys.Separator}, |
|
{0x6D, Keys.Subtract}, |
|
{0x6E, Keys.Decimal}, |
|
{0x6F, Keys.Divide}, |
|
{0x70, Keys.F1}, |
|
{0x71, Keys.F2}, |
|
{0x72, Keys.F3}, |
|
{0x73, Keys.F4}, |
|
{0x74, Keys.F5}, |
|
{0x75, Keys.F6}, |
|
{0x76, Keys.F7}, |
|
{0x77, Keys.F8}, |
|
{0x78, Keys.F9}, |
|
{0x79, Keys.F10}, |
|
{0x7A, Keys.F11}, |
|
{0x7B, Keys.F12}, |
|
{0x7C, Keys.F13}, |
|
{0x7D, Keys.F14}, |
|
{0x7E, Keys.F15}, |
|
{0x7F, Keys.F16}, |
|
{0x80, Keys.F17}, |
|
{0x81, Keys.F18}, |
|
{0x82, Keys.F19}, |
|
{0x83, Keys.F20}, |
|
{0x84, Keys.F21}, |
|
{0x85, Keys.F22}, |
|
{0x86, Keys.F23}, |
|
{0x87, Keys.F24}, |
|
{0x90, Keys.NumLock}, |
|
{0x91, Keys.ScrollLock}, |
|
{0xA0, Keys.LeftShift}, |
|
{0xA1, Keys.RightShift}, |
|
{0xA2, Keys.LeftControl}, |
|
{0xA3, Keys.RightControl}, |
|
{0xA4, Keys.LeftAlt}, |
|
{0xA5, Keys.RightAlt}, |
|
{0xA6, Keys.BrowserBack}, |
|
{0xA7, Keys.BrowserForward}, |
|
{0xA8, Keys.BrowserRefresh}, |
|
{0xA9, Keys.BrowserStop}, |
|
{0xAA, Keys.BrowserSearch}, |
|
{0xAB, Keys.BrowserFavorites}, |
|
{0xAC, Keys.BrowserHome}, |
|
{0xAD, Keys.VolumeMute}, |
|
{0xAE, Keys.VolumeDown}, |
|
{0xAF, Keys.VolumeUp}, |
|
{0xB0, Keys.MediaNextTrack}, |
|
{0xB1, Keys.MediaPreviousTrack}, |
|
{0xB2, Keys.MediaStop}, |
|
{0xB3, Keys.MediaPlayPause}, |
|
{0xB4, Keys.LaunchMail}, |
|
{0xB5, Keys.SelectMedia}, |
|
{0xB6, Keys.LaunchApplication1}, |
|
{0xB7, Keys.LaunchApplication2}, |
|
{0xBA, Keys.SemiColon}, |
|
{0xBA, Keys.SemiColon}, |
|
{0xBB, Keys.Plus}, |
|
{0xBC, Keys.Comma}, |
|
{0xBD, Keys.Minus}, |
|
{0xBE, Keys.Period}, |
|
{0xBF, Keys.QuestionMark}, |
|
{0xBF, Keys.QuestionMark}, |
|
{0xC0, Keys.OemTilde}, |
|
{0xC0, Keys.OemTilde}, |
|
{0xDB, Keys.OpenBracket}, |
|
{0xDB, Keys.OpenBracket}, |
|
{0xDC, Keys.OemPipe}, |
|
{0xDC, Keys.OemPipe}, |
|
{0xDD, Keys.CloseBracket}, |
|
{0xDD, Keys.CloseBracket}, |
|
{0xDE, Keys.Quote}, |
|
{0xDE, Keys.Quote}, |
|
{0xE2, Keys.Backslash}, |
|
{0xE2, Keys.Backslash}, |
|
{0xFA, Keys.Play}, |
|
{0xFB, Keys.Zoom}, |
|
{0xFE, Keys.Clear} |
|
}; |
|
|
|
private static readonly Dictionary<int, Keys> WinInputToKey = new() |
|
{ |
|
{0, Keys.None}, |
|
{1, Keys.Cancel}, |
|
{2, Keys.Backspace}, |
|
{3, Keys.Tab}, |
|
{5, Keys.Clear}, |
|
{6, Keys.Enter}, |
|
{6, Keys.Enter}, |
|
{7, Keys.Pause}, |
|
{8, Keys.CapsLock}, |
|
{8, Keys.CapsLock}, |
|
{13, Keys.Escape}, |
|
{18, Keys.Space}, |
|
{19, Keys.PageUp}, |
|
{19, Keys.PageUp}, |
|
{20, Keys.PageDown}, |
|
{20, Keys.PageDown}, |
|
{21, Keys.End}, |
|
{22, Keys.Home}, |
|
{23, Keys.ArrowLeft}, |
|
{24, Keys.ArrowUp}, |
|
{25, Keys.ArrowRight}, |
|
{26, Keys.ArrowDown}, |
|
{27, Keys.Select}, |
|
{28, Keys.Print}, |
|
{29, Keys.Execute}, |
|
{30, Keys.PrintScreen}, |
|
{30, Keys.PrintScreen}, |
|
{31, Keys.Insert}, |
|
{32, Keys.Delete}, |
|
{33, Keys.Help}, |
|
{34, Keys.D0}, |
|
{35, Keys.D1}, |
|
{36, Keys.D2}, |
|
{37, Keys.D3}, |
|
{38, Keys.D4}, |
|
{39, Keys.D5}, |
|
{40, Keys.D6}, |
|
{41, Keys.D7}, |
|
{42, Keys.D8}, |
|
{43, Keys.D9}, |
|
{44, Keys.A}, |
|
{45, Keys.B}, |
|
{46, Keys.C}, |
|
{47, Keys.D}, |
|
{48, Keys.E}, |
|
{49, Keys.F}, |
|
{50, Keys.G}, |
|
{51, Keys.H}, |
|
{52, Keys.I}, |
|
{53, Keys.J}, |
|
{54, Keys.K}, |
|
{55, Keys.L}, |
|
{56, Keys.M}, |
|
{57, Keys.N}, |
|
{58, Keys.O}, |
|
{59, Keys.P}, |
|
{60, Keys.Q}, |
|
{61, Keys.R}, |
|
{62, Keys.S}, |
|
{63, Keys.T}, |
|
{64, Keys.U}, |
|
{65, Keys.V}, |
|
{66, Keys.W}, |
|
{67, Keys.X}, |
|
{68, Keys.Y}, |
|
{69, Keys.Z}, |
|
{70, Keys.LeftMeta}, |
|
{71, Keys.RightMeta}, |
|
{72, Keys.Apps}, |
|
{73, Keys.Sleep}, |
|
{74, Keys.NumPad0}, |
|
{75, Keys.NumPad1}, |
|
{76, Keys.NumPad2}, |
|
{77, Keys.NumPad3}, |
|
{78, Keys.NumPad4}, |
|
{79, Keys.NumPad5}, |
|
{80, Keys.NumPad6}, |
|
{81, Keys.NumPad7}, |
|
{82, Keys.NumPad8}, |
|
{83, Keys.NumPad9}, |
|
{84, Keys.Multiply}, |
|
{85, Keys.Add}, |
|
{86, Keys.Separator}, |
|
{87, Keys.Subtract}, |
|
{88, Keys.Decimal}, |
|
{89, Keys.Divide}, |
|
{90, Keys.F1}, |
|
{91, Keys.F2}, |
|
{92, Keys.F3}, |
|
{93, Keys.F4}, |
|
{94, Keys.F5}, |
|
{95, Keys.F6}, |
|
{96, Keys.F7}, |
|
{97, Keys.F8}, |
|
{98, Keys.F9}, |
|
{99, Keys.F10}, |
|
{100, Keys.F11}, |
|
{101, Keys.F12}, |
|
{102, Keys.F13}, |
|
{103, Keys.F14}, |
|
{104, Keys.F15}, |
|
{105, Keys.F16}, |
|
{106, Keys.F17}, |
|
{107, Keys.F18}, |
|
{108, Keys.F19}, |
|
{109, Keys.F20}, |
|
{110, Keys.F21}, |
|
{111, Keys.F22}, |
|
{112, Keys.F23}, |
|
{113, Keys.F24}, |
|
{114, Keys.NumLock}, |
|
{115, Keys.ScrollLock}, |
|
{116, Keys.LeftShift}, |
|
{117, Keys.RightShift}, |
|
{118, Keys.LeftControl}, |
|
{119, Keys.RightControl}, |
|
{120, Keys.LeftAlt}, |
|
{121, Keys.RightAlt}, |
|
{122, Keys.BrowserBack}, |
|
{123, Keys.BrowserForward}, |
|
{124, Keys.BrowserRefresh}, |
|
{125, Keys.BrowserStop}, |
|
{126, Keys.BrowserSearch}, |
|
{127, Keys.BrowserFavorites}, |
|
{128, Keys.BrowserHome}, |
|
{129, Keys.VolumeMute}, |
|
{130, Keys.VolumeDown}, |
|
{131, Keys.VolumeUp}, |
|
{132, Keys.MediaNextTrack}, |
|
{133, Keys.MediaPreviousTrack}, |
|
{134, Keys.MediaStop}, |
|
{135, Keys.MediaPlayPause}, |
|
{136, Keys.LaunchMail}, |
|
{137, Keys.SelectMedia}, |
|
{138, Keys.LaunchApplication1}, |
|
{139, Keys.LaunchApplication2}, |
|
{140, Keys.SemiColon}, |
|
{140, Keys.SemiColon}, |
|
{141, Keys.Plus}, |
|
{142, Keys.Comma}, |
|
{143, Keys.Minus}, |
|
{144, Keys.Period}, |
|
{145, Keys.QuestionMark}, |
|
{145, Keys.QuestionMark}, |
|
{146, Keys.OemTilde}, |
|
{146, Keys.OemTilde}, |
|
{149, Keys.OpenBracket}, |
|
{149, Keys.OpenBracket}, |
|
{150, Keys.OemPipe}, |
|
{150, Keys.OemPipe}, |
|
{151, Keys.CloseBracket}, |
|
{151, Keys.CloseBracket}, |
|
{152, Keys.Quote}, |
|
{152, Keys.Quote}, |
|
{154, Keys.Backslash}, |
|
{154, Keys.Backslash}, |
|
{167, Keys.Play}, |
|
{168, Keys.Zoom}, |
|
{171, Keys.Clear} |
|
}; |
|
|
|
private static readonly Dictionary<int, Keys> WinFormToKey = new() |
|
{ |
|
{0, Keys.None}, |
|
{3, Keys.Cancel}, |
|
{8, Keys.Backspace}, |
|
{9, Keys.Tab}, |
|
{12, Keys.Clear}, |
|
{13, Keys.Enter}, |
|
{13, Keys.Enter}, |
|
{19, Keys.Pause}, |
|
{20, Keys.CapsLock}, |
|
{20, Keys.CapsLock}, |
|
{27, Keys.Escape}, |
|
{32, Keys.Space}, |
|
{33, Keys.PageUp}, |
|
{33, Keys.PageUp}, |
|
{34, Keys.PageDown}, |
|
{34, Keys.PageDown}, |
|
{35, Keys.End}, |
|
{36, Keys.Home}, |
|
{37, Keys.ArrowLeft}, |
|
{38, Keys.ArrowUp}, |
|
{39, Keys.ArrowRight}, |
|
{40, Keys.ArrowDown}, |
|
{41, Keys.Select}, |
|
{42, Keys.Print}, |
|
{43, Keys.Execute}, |
|
{44, Keys.PrintScreen}, |
|
{44, Keys.PrintScreen}, |
|
{45, Keys.Insert}, |
|
{46, Keys.Delete}, |
|
{47, Keys.Help}, |
|
{48, Keys.D0}, |
|
{49, Keys.D1}, |
|
{50, Keys.D2}, |
|
{51, Keys.D3}, |
|
{52, Keys.D4}, |
|
{53, Keys.D5}, |
|
{54, Keys.D6}, |
|
{55, Keys.D7}, |
|
{56, Keys.D8}, |
|
{57, Keys.D9}, |
|
{65, Keys.A}, |
|
{66, Keys.B}, |
|
{67, Keys.C}, |
|
{68, Keys.D}, |
|
{69, Keys.E}, |
|
{70, Keys.F}, |
|
{71, Keys.G}, |
|
{72, Keys.H}, |
|
{73, Keys.I}, |
|
{74, Keys.J}, |
|
{75, Keys.K}, |
|
{76, Keys.L}, |
|
{77, Keys.M}, |
|
{78, Keys.N}, |
|
{79, Keys.O}, |
|
{80, Keys.P}, |
|
{81, Keys.Q}, |
|
{82, Keys.R}, |
|
{83, Keys.S}, |
|
{84, Keys.T}, |
|
{85, Keys.U}, |
|
{86, Keys.V}, |
|
{87, Keys.W}, |
|
{88, Keys.X}, |
|
{89, Keys.Y}, |
|
{90, Keys.Z}, |
|
{91, Keys.LeftMeta}, |
|
{92, Keys.RightMeta}, |
|
{93, Keys.Apps}, |
|
{95, Keys.Sleep}, |
|
{96, Keys.NumPad0}, |
|
{97, Keys.NumPad1}, |
|
{98, Keys.NumPad2}, |
|
{99, Keys.NumPad3}, |
|
{100, Keys.NumPad4}, |
|
{101, Keys.NumPad5}, |
|
{102, Keys.NumPad6}, |
|
{103, Keys.NumPad7}, |
|
{104, Keys.NumPad8}, |
|
{105, Keys.NumPad9}, |
|
{106, Keys.Multiply}, |
|
{107, Keys.Add}, |
|
{108, Keys.Separator}, |
|
{109, Keys.Subtract}, |
|
{110, Keys.Decimal}, |
|
{111, Keys.Divide}, |
|
{112, Keys.F1}, |
|
{113, Keys.F2}, |
|
{114, Keys.F3}, |
|
{115, Keys.F4}, |
|
{116, Keys.F5}, |
|
{117, Keys.F6}, |
|
{118, Keys.F7}, |
|
{119, Keys.F8}, |
|
{120, Keys.F9}, |
|
{121, Keys.F10}, |
|
{122, Keys.F11}, |
|
{123, Keys.F12}, |
|
{124, Keys.F13}, |
|
{125, Keys.F14}, |
|
{126, Keys.F15}, |
|
{127, Keys.F16}, |
|
{128, Keys.F17}, |
|
{129, Keys.F18}, |
|
{130, Keys.F19}, |
|
{131, Keys.F20}, |
|
{132, Keys.F21}, |
|
{133, Keys.F22}, |
|
{134, Keys.F23}, |
|
{135, Keys.F24}, |
|
{144, Keys.NumLock}, |
|
{145, Keys.ScrollLock}, |
|
{160, Keys.LeftShift}, |
|
{161, Keys.RightShift}, |
|
{162, Keys.LeftControl}, |
|
{163, Keys.RightControl}, |
|
{164, Keys.LeftAlt}, |
|
{165, Keys.RightAlt}, |
|
{166, Keys.BrowserBack}, |
|
{167, Keys.BrowserForward}, |
|
{168, Keys.BrowserRefresh}, |
|
{169, Keys.BrowserStop}, |
|
{170, Keys.BrowserSearch}, |
|
{171, Keys.BrowserFavorites}, |
|
{172, Keys.BrowserHome}, |
|
{173, Keys.VolumeMute}, |
|
{174, Keys.VolumeDown}, |
|
{175, Keys.VolumeUp}, |
|
{176, Keys.MediaNextTrack}, |
|
{177, Keys.MediaPreviousTrack}, |
|
{178, Keys.MediaStop}, |
|
{179, Keys.MediaPlayPause}, |
|
{180, Keys.LaunchMail}, |
|
{181, Keys.SelectMedia}, |
|
{182, Keys.LaunchApplication1}, |
|
{183, Keys.LaunchApplication2}, |
|
{186, Keys.SemiColon}, |
|
{186, Keys.SemiColon}, |
|
{187, Keys.Plus}, |
|
{188, Keys.Comma}, |
|
{189, Keys.Minus}, |
|
{190, Keys.Period}, |
|
{191, Keys.QuestionMark}, |
|
{191, Keys.QuestionMark}, |
|
{192, Keys.OemTilde}, |
|
{192, Keys.OemTilde}, |
|
{219, Keys.OpenBracket}, |
|
{219, Keys.OpenBracket}, |
|
{220, Keys.OemPipe}, |
|
{220, Keys.OemPipe}, |
|
{221, Keys.CloseBracket}, |
|
{221, Keys.CloseBracket}, |
|
{222, Keys.Quote}, |
|
{222, Keys.Quote}, |
|
{226, Keys.Backslash}, |
|
{226, Keys.Backslash}, |
|
{250, Keys.Play}, |
|
{251, Keys.Zoom}, |
|
{254, Keys.Clear} |
|
}; |
|
|
|
public KeyboardKey(Keys key) |
|
{ |
|
this.key = key; |
|
} |
|
|
|
public int win32Key { get; protected set; } |
|
public int winInputKey { get; protected set; } |
|
public int winFormKey { get; protected set; } |
|
public string jsKey { get; protected set; } |
|
|
|
public Keys key { get; } |
|
|
|
public KeySource keySource { get; protected set; } = KeySource.Internal; |
|
|
|
public string keyName => key.ToString(); |
|
|
|
public int keyCode => (int) key; |
|
|
|
public static KeyboardKey FromJs(string key) => |
|
JsToKeys.ContainsKey(key) ? new KeyboardKey(JsToKeys[key]) : new KeyboardKey(Keys.Unknown) {jsKey = key, keySource = KeySource.JavaScript}; |
|
|
|
public static KeyboardKey FromWin32(int key) => Win32ToKey.ContainsKey(key) |
|
? new KeyboardKey(Win32ToKey[key]) |
|
: new KeyboardKey(Keys.Unknown) {win32Key = key, keySource = KeySource.Win32}; |
|
|
|
public static KeyboardKey FromWinInput(int key) => WinInputToKey.ContainsKey(key) |
|
? new KeyboardKey(WinInputToKey[key]) |
|
: new KeyboardKey(Keys.Unknown) {winInputKey = key, keySource = KeySource.WinInput}; |
|
|
|
public static KeyboardKey FromWinForm(int key) => WinFormToKey.ContainsKey(key) |
|
? new KeyboardKey(WinFormToKey[key]) |
|
: new KeyboardKey(Keys.Unknown) {winFormKey = key, keySource = KeySource.WinForm}; |
|
|
|
public int ToWin32Key() => KeyToValues[key][2]; |
|
|
|
public int ToWinInputKey() => KeyToValues[key][0]; |
|
|
|
public int ToWinFormKey() => KeyToValues[key][1]; |
|
|
|
public string ToJavaScriptKey() => KeyToJsValues[key]; |
|
|
|
public override string ToString() => keyName; |
|
public bool Equals(KeyboardKey other) |
|
{ |
|
if (ReferenceEquals(null, other)) |
|
return false; |
|
if (ReferenceEquals(this, other)) |
|
return true; |
|
return key == other.key; |
|
} |
|
public override bool Equals(object obj) => ReferenceEquals(this, obj) || obj is KeyboardKey other && Equals(other); |
|
public override int GetHashCode() => keyCode; |
|
public static bool operator ==(KeyboardKey left, KeyboardKey right) => Equals(left, right); |
|
public static bool operator !=(KeyboardKey left, KeyboardKey right) => !Equals(left, right); |
|
} |
{0x2C, Keys.PrintScreen},
{0x2C, Keys.PrintScreen},
seems repeat.