其中 combinationVKButtonsMap 是一個 IDictionary<short, IList<KeyboardButton>>, key 存儲的是
VK_SHIFT, VK_CONTROL 等組合鍵的鍵盤碼。左右兩個按鈕對應同一個鍵 盤碼,因此需要放在一個 List 裡。
標准鍵盤上的每一個鍵都有虛擬鍵碼 ( VK_CODE)與之對應。還有一些其他的常量,
把它寫在一個靜態 class 裡吧。
1 // KeyboardConstaint.cs 2 internal static class KeyboardConstaint { 3 internal static readonly short VK_F1 = 0x70; 4 internal static readonly short VK_F2 = 0x71; 5 internal static readonly short VK_F3 = 0x72; 6 internal static readonly short VK_F4 = 0x73; 7 internal static readonly short VK_F5 = 0x74; 8 internal static readonly short VK_F6 = 0x75; 9 internal static readonly short VK_F7 = 0x76; 10 internal static readonly short VK_F8 = 0x77; 11 internal static readonly short VK_F9 = 0x78; 12 internal static readonly short VK_F10 = 0x79; 13 internal static readonly short VK_F11 = 0x7A; 14 internal static readonly short VK_F12 = 0x7B; 15 16 internal static readonly short VK_LEFT = 0x25; 17 internal static readonly short VK_UP = 0x26; 18 internal static readonly short VK_RIGHT = 0x27; 19 internal static readonly short VK_DOWN = 0x28; 20 21 internal static readonly short VK_NONE = 0x00; 22 internal static readonly short VK_ESCAPE = 0x1B; 23 internal static readonly short VK_EXECUTE = 0x2B; 24 internal static readonly short VK_CANCEL = 0x03; 25 internal static readonly short VK_RETURN = 0x0D; 26 internal static readonly short VK_ACCEPT = 0x1E; 27 internal static readonly short VK_BACK = 0x08; 28 internal static readonly short VK_TAB = 0x09; 29 internal static readonly short VK_DELETE = 0x2E; 30 internal static readonly short VK_CAPITAL = 0x14; 31 internal static readonly short VK_NUMLOCK = 0x90; 32 internal static readonly short VK_SPACE = 0x20; 33 internal static readonly short VK_DECIMAL = 0x6E; 34 internal static readonly short VK_SUBTRACT = 0x6D; 35 36 internal static readonly short VK_ADD = 0x6B; 37 internal static readonly short VK_DIVIDE = 0x6F; 38 internal static readonly short VK_MULTIPLY = 0x6A; 39 internal static readonly short VK_INSERT = 0x2D; 40 41 internal static readonly short VK_OEM_1 = 0xBA; // ';:' for US 42 internal static readonly short VK_OEM_PLUS = 0xBB; // '+' any country 43 44 internal static readonly short VK_OEM_MINUS = 0xBD; // '-' any country 45 46 internal static readonly short VK_OEM_2 = 0xBF; // '/?' for US 47 internal static readonly short VK_OEM_3 = 0xC0; // '`~' for US 48 internal static readonly short VK_OEM_4 = 0xDB; // '[{' for US 49 internal static readonly short VK_OEM_5 = 0xDC; // '\|' for US 50 internal static readonly short VK_OEM_6 = 0xDD; // ']}' for US 51 internal static readonly short VK_OEM_7 = 0xDE; // ''"' for US 52 internal static readonly short VK_OEM_PERIOD = 0xBE; // '.>' any country 53 internal static readonly short VK_OEM_COMMA = 0xBC; // ',<' any country 54 internal static readonly short VK_SHIFT = 0x10; 55 internal static readonly short VK_CONTROL = 0x11; 56 internal static readonly short VK_MENU = 0x12; 57 internal static readonly short VK_LWIN = 0x5B; 58 internal static readonly short VK_RWIN = 0x5C; 59 internal static readonly short VK_APPS = 0x5D; 60 61 internal static readonly short VK_LSHIFT = 0xA0; 62 internal static readonly short VK_RSHIFT = 0xA1; 63 internal static readonly short VK_LCONTROL = 0xA2; 64 internal static readonly short VK_RCONTROL = 0xA3; 65 internal static readonly short VK_LMENU = 0xA4; 66 internal static readonly short VK_RMENU = 0xA5; 67 68 internal static readonly short VK_SNAPSHOT = 0x2C; 69 internal static readonly short VK_SCROLL = 0x91; 70 internal static readonly short VK_PAUSE = 0x13; 71 internal static readonly short VK_HOME = 0x24; 72 73 internal static readonly short VK_NEXT = 0x22; 74 internal static readonly short VK_PRIOR = 0x21; 75 internal static readonly short VK_END = 0x23; 76 77 internal static readonly short VK_NUMPAD0 = 0x60; 78 internal static readonly short VK_NUMPAD1 = 0x61; 79 internal static readonly short VK_NUMPAD2 = 0x62; 80 internal static readonly short VK_NUMPAD3 = 0x63; 81 internal static readonly short VK_NUMPAD4 = 0x64; 82 internal static readonly short VK_NUMPAD5 = 0x65; 83 internal static readonly short VK_NUMPAD5NOTHING = 0x0C; 84 internal static readonly short VK_NUMPAD6 = 0x66; 85 internal static readonly short VK_NUMPAD7 = 0x67; 86 internal static readonly short VK_NUMPAD8 = 0x68; 87 internal static readonly short VK_NUMPAD9 = 0x69; 88 89 internal static readonly short KEYEVENTF_EXTENDEDKEY = 0x0001; 90 internal static readonly short KEYEVENTF_KEYUP = 0x0002; 91 92 internal static readonly int GWL_EXSTYLE = -20; 93 internal static readonly int WS_DISABLED = 0X8000000; 94 internal static readonly int WM_SETFOCUS = 0X0007; 95 }