SimpleWindow
载入中...
搜索中...
未找到
Keys.h
1#pragma once
2
3#include "EnumBit.h"
4#include <Windows.h>
5#include <cstdint>
6
7namespace sw
8{
12 struct KeyFlags {
13 // repeat count, > 0 if several keydown messages was combined into one message
14 uint16_t repeatCount;
15
16 // scan code
17 uint8_t scanCode;
18
19 // extended-key flag, 1 if scancode has 0xE0 prefix
20 bool isExtendedKey;
21
22 // indicates whether the ALT key was down
23 bool contextCode;
24
25 // indicates whether the key that generated the keystroke message was previously up or down
26 bool previousKeyState;
27
28 // transition-state flag, 1 on keyup
29 bool transitionState;
30
31 // 默认构造函数
32 KeyFlags() = default;
33
34 // 从lParam解析出各个字段
35 KeyFlags(LPARAM lParam);
36 };
37
41 enum class VirtualKey {
42 MouseLeft = 0x01, // Left mouse button
43 MouseRight = 0x02, // Right mouse button
44 Cancel = 0x03, // Control-break processing
45 MouseMiddle = 0x04, // Middle mouse button (three-button mouse)
46 MouseX1 = 0x05, // X1 mouse button
47 MouseX2 = 0x06, // X2 mouse button
48
49 //- 0x07 Undefined
50
51 Backspace = 0x08, // BACKSPACE key
52 Tab = 0x09, // TAB key
53
54 //- 0x0A-0B Reserved
55
56 Clear = 0x0C, // CLEAR key
57 Enter = 0x0D, // ENTER key
58
59 //- 0x0E-0F Undefined
60
61 Shift = 0x10, // SHIFT key
62 Ctrl = 0x11, // CTRL key
63 Alt = 0x12, // ALT key
64 Pause = 0x13, // PAUSE key
65 CapsLock = 0x14, // CAPS LOCK key
66 Kana = 0x15, // IME Kana mode
67 Hanguel = 0x15, // IME Hanguel mode (maintained for compatibility; use VK_HANGUL)
68 Hangul = 0x15, // IME Hangul mode
69 IME_On = 0x16, // IME On
70 Junja = 0x17, // IME Junja mode
71 Final = 0x18, // IME final mode
72 Hanja = 0x19, // IME Hanja mode
73 KANJI = 0x19, // IME Kanji mode
74 IME_Off = 0x1A, // IME Off
75 Esc = 0x1B, // ESC key
76 Convert = 0x1C, // IME convert
77 Nonconvert = 0x1D, // IME nonconvert
78 Accept = 0x1E, // IME accept
79 ModeChange = 0x1F, // IME mode change request
80 Space = 0x20, // SPACEBAR
81 PageUp = 0x21, // PAGE UP key
82 PageDown = 0x22, // PAGE DOWN key
83 End = 0x23, // END key
84 Home = 0x24, // HOME key
85 Left = 0x25, // LEFT ARROW key
86 Up = 0x26, // UP ARROW key
87 Right = 0x27, // RIGHT ARROW key
88 Down = 0x28, // DOWN ARROW key
89 Select = 0x29, // SELECT key
90 Print = 0x2A, // PRINT key
91 Execute = 0x2B, // EXECUTE key
92 Snapshot = 0x2C, // PRINT SCREEN key
93 Insert = 0x2D, // INS key
94 Delete = 0x2E, // DEL key
95 Help = 0x2F, // HELP key
96
97 Zero = 0x30, // 0 key
98 One = 0x31, // 1 key
99 Two = 0x32, // 2 key
100 Three = 0x33, // 3 key
101 Four = 0x34, // 4 key
102 Five = 0x35, // 5 key
103 Six = 0x36, // 6 key
104 Seven = 0x37, // 7 key
105 Eight = 0x38, // 8 key
106 Nine = 0x39, // 9 key
107
108 //- 0x3A-40 Undefined
109
110 A = 0x41, // A key
111 B = 0x42, // B key
112 C = 0x43, // C key
113 D = 0x44, // D key
114 E = 0x45, // E key
115 F = 0x46, // F key
116 G = 0x47, // G key
117 H = 0x48, // H key
118 I = 0x49, // I key
119 J = 0x4A, // J key
120 K = 0x4B, // K key
121 L = 0x4C, // L key
122 M = 0x4D, // M key
123 N = 0x4E, // N key
124 O = 0x4F, // O key
125 P = 0x50, // P key
126 Q = 0x51, // Q key
127 R = 0x52, // R key
128 S = 0x53, // S key
129 T = 0x54, // T key
130 U = 0x55, // U key
131 V = 0x56, // V key
132 W = 0x57, // W key
133 X = 0x58, // X key
134 Y = 0x59, // Y key
135 Z = 0x5A, // Z key
136
137 LeftWindows = 0x5B, // Left Windows key (Natural keyboard)
138 RightWindows = 0x5C, // Right Windows key (Natural keyboard)
139 Applications = 0x5D, // Applications key (Natural keyboard)
140
141 //- 0x5E Reserved
142
143 Sleep = 0x5F, // Computer Sleep key
144 NumPad0 = 0x60, // Numeric keypad 0 key
145 NumPad1 = 0x61, // Numeric keypad 1 key
146 NumPad2 = 0x62, // Numeric keypad 2 key
147 NumPad3 = 0x63, // Numeric keypad 3 key
148 NumPad4 = 0x64, // Numeric keypad 4 key
149 NumPad5 = 0x65, // Numeric keypad 5 key
150 NumPad6 = 0x66, // Numeric keypad 6 key
151 NumPad7 = 0x67, // Numeric keypad 7 key
152 NumPad8 = 0x68, // Numeric keypad 8 key
153 NumPad9 = 0x69, // Numeric keypad 9 key
154 Multipy = 0x6A, // Multiply key
155 Add = 0x6B, // Add key
156 Separator = 0x6C, // Separator key
157 Subtract = 0x6D, // Subtract key
158 Decimal = 0x6E, // Decimal key
159 Divide = 0x6F, // Divide key
160 F1 = 0x70, // F1 key
161 F2 = 0x71, // F2 key
162 F3 = 0x72, // F3 key
163 F4 = 0x73, // F4 key
164 F5 = 0x74, // F5 key
165 F6 = 0x75, // F6 key
166 F7 = 0x76, // F7 key
167 F8 = 0x77, // F8 key
168 F9 = 0x78, // F9 key
169 F10 = 0x79, // F10 key
170 F11 = 0x7A, // F11 key
171 F12 = 0x7B, // F12 key
172 F13 = 0x7C, // F13 key
173 F14 = 0x7D, // F14 key
174 F15 = 0x7E, // F15 key
175 F16 = 0x7F, // F16 key
176 F17 = 0x80, // F17 key
177 F18 = 0x81, // F18 key
178 F19 = 0x82, // F19 key
179 F20 = 0x83, // F20 key
180 F21 = 0x84, // F21 key
181 F22 = 0x85, // F22 key
182 F23 = 0x86, // F23 key
183 F24 = 0x87, // F24 key
184
185 //- 0x88-8F Unassigned
186
187 NumLock = 0x90, // NUM LOCK key
188 ScrollLock = 0x91, // SCROLL LOCK key
189
190 // 0x92-96 OEM specific
191 //- 0x97-9F Unassigned
192
193 LeftShift = 0xA0, // Left SHIFT key
194 RightShift = 0xA1, // Right SHIFT key
195 LeftCtrl = 0xA2, // Left CONTROL key
196 RightCtrl = 0xA3, // Right CONTROL key
197 LeftAlt = 0xA4, // Left ALT key
198 RightAlt = 0xA5, // Right ALT key
199 BrowserBack = 0xA6, // Browser Back key
200 BrowserForward = 0xA7, // Browser Forward key
201 BrowserRefresh = 0xA8, // Browser Refresh key
202 BrowserStop = 0xA9, // Browser Stop key
203 BrowserSearch = 0xAA, // Browser Search key
204 BrowserFavorites = 0xAB, // Browser Favorites key
205 BrowserHome = 0xAC, // Browser Start and Home key
206 VolumeMute = 0xAD, // Volume Mute key
207 VolumeDown = 0xAE, // Volume Down key
208 VolumeUp = 0xAF, // Volume Up key
209 MediaNextTrack = 0xB0, // Next Track key
210 MediaPreviousTrack = 0xB1, // Previous Track key
211 MediaStop = 0xB2, // Stop Media key
212 MediaPlayPause = 0xB3, // Play/Pause Media key
213 LaunchMail = 0xB4, // Start Mail key
214 LaunchMediaSelect = 0xB5, // Select Media key
215 LaunchApplication1 = 0xB6, // Start Application 1 key
216 LaunchApplication2 = 0xB7, // Start Application 2 key
217
218 //- 0xB8-B9 Reserved
219
220 OEM_1 = 0xBA, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ';:' key
221 OEM_Plus = 0xBB, // For any country/region, the '+' key
222 OEM_Comma = 0xBC, // For any country/region, the ',' key
223 OEM_Minus = 0xBD, // For any country/region, the '-' key
224 OEM_Period = 0xBE, // For any country/region, the '.' key
225 OEM_2 = 0xBF, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '/?' key
226 OEM_3 = 0xC0, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '`~' key
227
228 //- 0xC1-D7 Reserved
229 //- 0xD8-DA Unassigned
230
231 OEM_4 = 0xDB, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '[{' key
232 OEM_5 = 0xDC, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the '\|' key
233 OEM_6 = 0xDD, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the ']}' key
234 OEM_7 = 0xDE, // Used for miscellaneous characters; it can vary by keyboard. For the US standard keyboard, the 'single-quote/double-quote' key
235 OEM_8 = 0xDF, // Used for miscellaneous characters; it can vary by keyboard.
236
237 //- 0xE0 Reserved
238 // 0xE1 OEM specific
239
240 OEM_102 = 0xE2, // The <> keys on the US standard keyboard, or the \\| key on the non-US 102-key keyboard
241
242 // 0xE3-E4 OEM specific
243
244 ProcessKey = 0xE5, // IME PROCESS key
245
246 // 0xE6 OEM specific
247
248 Packet = 0xE7, // Used to pass Unicode characters as if they were keystrokes. The VK_PACKET key is the low word of a 32-bit Virtual Key value used for non-keyboard input methods. For more information, see Remark in KEYBDINPUT, SendInput, WM_KEYDOWN, and WM_KEYUP
249
250 //- 0xE8 Unassigned
251 // 0xE9-F5 OEM specific
252
253 Attn = 0xF6, // Attn key
254 CrSel = 0xF7, // CrSel key
255 ExSel = 0xF8, // ExSel key
256 EraseEOF = 0xF9, // Erase EOF key
257 Play = 0xFA, // Play key
258 Zoom = 0xFB, // Zoom key
259 NONAME = 0xFC, // Reserved
260 PA1 = 0xFD, // PA1 key
261 OEM_Clear = 0xFE, // Clear key
262 };
263
267 enum class MouseKey {
268 Ctrl = MK_CONTROL, // The CTRL key is down.
269 MouseLeft = MK_LBUTTON, // The left mouse button is down.
270 MouseMiddle = MK_MBUTTON, // The middle mouse button is down.
271 MouseRight = MK_RBUTTON, // The right mouse button is down.
272 Shift = MK_SHIFT, // The SHIFT key is down.
273 MouseX1 = MK_XBUTTON1, // The first X button is down.
274 MouseX2 = MK_XBUTTON2, // The second X button is down.
275 };
276
280 _SW_ENUM_ENABLE_BIT_OPERATIONS(MouseKey);
281
285 enum class HotKeyModifier {
286 None = 0, // 无按键
287 Shift = /*HOTKEYF_SHIFT*/ 0x1, // Alt键
288 Ctrl = /*HOTKEYF_CONTROL*/ 0x2, // Ctrl键
289 Alt = /*HOTKEYF_ALT*/ 0x4, // 扩展键
290 Ext = /*HOTKEYF_EXT*/ 0x8, // Shift键
291 };
292
296 _SW_ENUM_ENABLE_BIT_OPERATIONS(HotKeyModifier);
297}
https://learn.microsoft.com/en-us/windows/win32/inputdev/about-keyboard-input#keystroke-message-flags
Definition Keys.h:12