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