vb.net 英国键盘的 .KeyDown 事件返回的键码是什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36715562/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 19:49:40  来源:igfitidea点击:

What are the Keycodes returned by the .KeyDown event for UK Keyboards

c#.netvb.netkeydown

提问by David Wilson

Is there a list of the keycodes returned by VB.Net and C# in the .KeyDown Event? The values returned don't match the usual ASCII codes.

.KeyDown 事件中是否有 VB.Net 和 C# 返回的键码列表?返回的值与通常的 ASCII 代码不匹配。

回答by Matt Wilko

These values are all part of the Keys Enumeration.

这些值都是Keys Enumeration 的一部分。

The actualvalues of these (as with all Enums) are arbitrary, so you should never write code that compares this to a numeric value. They could possibly change value with a framework update for example.

这些的实际值(与所有 Enum 一样)是任意的,因此您永远不应该编写将其与数值进行比较的代码。例如,他们可能会通过框架更新来改变价值。

It just so happens the A-Zcorrespond to the ASCII values for A-Z, but again you shouldn't rely on this.

恰好A-Z对应于 的 ASCII 值A-Z,但您不应该依赖于此。

Intellisense shows you these keys (with each individual value) when appropriate:

Intellisense 在适当的时候向您显示这些键(带有每个单独的值):

enter image description here

在此处输入图片说明

And you can also search in the object browser (F11) for Windows.System.Forms.Keysand you will see the full list (with values):

您还可以在对象浏览器 (F11) 中搜索Windows.System.Forms.Keys,您将看到完整列表(带值):

enter image description here

在此处输入图片说明

回答by David Wilson

0 No key pressed

0 没有按键

1 The LEFT MOUSE Button

1 鼠标左键

2 The RIGHT MOUSE Button

2 鼠标右键

3 CANCEL KEY

3 取消键

4 The MIDDLE MOUSE Button (three-button mouse)

4 MIDDLE MOUSE Button(三键鼠标)

5 The first x mouse button (five-button mouse)

5 第一个 x 鼠标键(五键鼠标)

6 The second x mouse button (five-button mouse)

6 第二个 x 鼠标键(五键鼠标)

7 Undefined

7 未定义

8 BACKSPACE

8 退格

9 TAB

9 选项卡

10 The LINEFEED key

10 换行键

11 Undefined

11 未定义

12 CLEAR key

12 清除键

13 RETURN/ENTER KEY (next to letters) also ENTER KEY (on number-pad)

13 RETURN/ENTER KEY(字母旁边)还有 ENTER KEY(在数字键盘上)

14 Undefined

14 未定义

15 Undefined

15 未定义

16 SHIFT

16 档

17 CTRL

17 控制

18 ALT

18 ALT

19 PAUSE / BREAK

19 暂停/休息

20 CAPS LOCK

20 大写锁定

21 The IME Hanguel mode key / The IME Kana mode key

21 IME 韩文模式键/ IME 假名模式键

22 Undefined

22 未定义

23 The IME Junja mode key

23 IME Junja 模式键

24 The IME final mode key

24 IME 最终模式键

25 The IME Hanja mode key / The IME Kanji mode key

25 IME 汉字模式键 / IME 汉字模式键

26 Undefined

26 未定义

27 ESC

27电调

28 The IME convert key

28 IME 转换键

29 The IME nonconvert key

29 IME 非转换键

30 The IME accept key

30 IME 接受键

31 The IME mode change key

31 IME 模式更改键

32 SPACE BAR

32 空格键

33 PAGE UP / PGUP KEY

33 PAGE UP / PGUP 键

34 PAGE DOWN / PGDN KEY

34 向下翻页 / PGDN 键

35 END

35 结束

36 HOME

36家

37 LEFT ARROW KEY

37 左箭头键

38 UP ARROW KEY

38 向上箭头键

39 RIGHT ARROW KEY

39 右箭头键

40 DOWN ARROW KEY

40 向下箭头键

41 The SELECT key

41 选择键

42 The PRINT key

42 打印键

43 The EXECUTE key

43 执行键

44 The PRINT SCREEN key

44 打印屏幕键

45 INSERT

45 插入

46 DELETE

46 删除

47 The HELP key

47 帮助键

48 0/) KEY ON KEYBOARD (above letters)

48 0/) 键盘上的按键(字母上方)

49 1/! KEY ON KEYBOARD (above letters)

49 1/! KEY ON KEYBOARD(字母上方)

50 2/@ KEY ON KEYBOARD (above letters)

50 2/@ KEY ON KEYBOARD(字母上方)

51 3/# KEY ON KEYBOARD (above letters)

51 3/# KEY ON KEYBOARD(字母上方)

52 4/$ KEY ON KEYBOARD (above letters)

52 4/$ KEY ON KEYBOARD(字母上方)

53 5/% KEY ON KEYBOARD (above letters)

53 5/% KEY ON KEYBOARD(字母上方)

54 6/^ KEY ON KEYBOARD (above letters)

54 6/^ 键盘上的按键(字母上方)

55 7/& KEY ON KEYBOARD (above letters)

55 7/& KEY ON KEYBOARD(字母上方)

56 8/* KEY ON KEYBOARD (above letters)

56 8/* KEY ON KEYBOARD (以上字母)

57 9/( KEY ON KEYBOARD (above letters)

57 9/( KEY ON KEYBOARD (以上字母)

58 Undefined

58 未定义

59 Undefined

59 未定义

60 Undefined

60 未定义

61 Undefined

61 未定义

62 Undefined

62 未定义

63 Undefined

63 未定义

64 Undefined

64 未定义

65 A and a KEY

65A和钥匙

66 B and b KEY

66 B 和 B 键

67 C and c KEY

67 C 和 c 键

68 D and d KEY

68 D 和 d 键

69 E and e KEY

69 E 和 e 键

70 F and f KEY

70 F 和 f 键

71 G and g KEY

71 G 和 g 键

72 H and h KEY

72 H 和 h 键

73 I and i KEY

73 我和我的钥匙

74 J and j KEY

74 J 和 j 键

75 K and k KEY

75 K 和 k KEY

76 L and l KEY

76 L 和 L 键

77 M and m KEY

77 M 和 m KEY

78 N and n KEY

78 N 和 n 键

79 O and o KEY

79 O 和 o 键

80 P and p KEY

80 P 和 P 键

81 Q and q KEY

第81话

82 R and r KEY

82 R 和 r 键

83 S and s KEY

83 S和S键

84 T and t KEY

84 T 和 t 键

85 U and u KEY

85 U 和 u 键

86 V and v KEY

86 V 和 v 键

87 W and w KEY

87 W 和 W KEY

88 X and x KEY

88 X 和 X 键

89 Y and y KEY

89 Y 和 Y 键

90 Z and z KEY

90 Z 和 z 键

91 The left Windows logo key

91 左 Windows 徽标键

92 The right Windows logo key

92 正确的 Windows 徽标键

93 CONTEXT-MENU KEY (KEY WHICH SIMULATES A RIGHT-MOUSE CLICK)

93 上下文菜单键(模拟鼠标右键单击的键)

94 Reserved

94 保留

95 SLEEP/STANDBY KEY ON KEYBOARD

95 键盘上的睡眠/待机键

96 0 KEY (on number-pad)

96 0 KEY(在数字键盘上)

97 1 KEY (on number-pad)

97 1 KEY(在数字键盘上)

98 2 KEY (on number-pad)

98 2 KEY(在数字键盘上)

99 3 KEY (on number-pad)

99 3 KEY(在数字键盘上)

100 4 KEY (on number-pad)

100 4 KEY(在数字键盘上)

101 5 KEY (on number-pad)

101 5 KEY(在数字键盘上)

102 6 KEY (on number-pad)

102 6 KEY(在数字键盘上)

103 7 KEY (on number-pad)

103 7 KEY(在数字键盘上)

104 8 KEY (on number-pad)

104 8 KEY(在数字键盘上)

105 9 KEY (on number-pad)

105 9 KEY(在数字键盘上)

106 * KEY (on number-pad)

106 * KEY(在数字键盘上)

107 + KEY (on number-pad)

107 + KEY(在数字键盘上)

108 The separator key (ENTER key on number-pad)

108 分隔键(数字键盘上的 ENTER 键)

109 - KEY (on number-pad)

109 - KEY(在数字键盘上)

110 . KEY (on number-pad)

110 . KEY(在数字键盘上)

111 / KEY (on number-pad)

111 / KEY(在数字键盘上)

112 F1

112 F1

113 F2

113 F2

114 F3

114 F3

115 F4

115 F4

116 F5

116 F5

117 F6

117 F6

118 F7

118 F7

119 F8

119 F8

120 F9

120 F9

121 F10

121 F10

122 F11

122 F11

123 F12

123 F12

124 F13

124 F13

125 F14

125 F14

126 F15

126 F15

127 F16

127 F16

128 F17

128 F17

129 F18

129 F18

130 F19

130 F19

131 F20

131 F20

132 F21

132 F21

133 F22

133 F22

134 F23

134 F23

135 F24

135 F24

136 Unassigned

136 未分配

137 Unassigned

137 未分配

138 Unassigned

138 未分配

139 Unassigned

139 未分配

140 Unassigned

140 未分配

141 Unassigned

141 未分配

142 Unassigned

142 未分配

143 Unassigned

143 未分配

144 NUM LOCK

144 数字锁

145 SCROLL LOCK

145 卷轴锁

146 OEM specific

146 OEM 专用

147 OEM specific

147 OEM 专用

148 OEM specific

148 OEM 专用

149 OEM specific

149 OEM 专用

150 OEM specific

150 OEM 专用

151 Unassigned

151 未分配

152 Unassigned

152 未分配

153 Unassigned

153 未分配

154 Unassigned

154 未分配

155 Unassigned

155 未分配

156 Unassigned

156 未分配

157 Unassigned

157 未分配

158 Unassigned

158 未分配

159 Unassigned

159 未分配

160 The left SHIFT key

160左SHIFT键

161 The right SHIFT key

161 右SHIFT键

162 The left CTRL key

162 左CTRL键

163 The right CTRL key

163 右​​CTRL键

164 The left ALT key

164 左ALT键

165 The right ALT key

165 右ALT键

166 BROWSER BACK KEY ON KEYBOARD / INTERNET-CONTROL (Windows 2000 or later)

166 键盘上的浏览器后退键/互联网控制(Windows 2000 或更高版本)

167 BROWSER FORWARD KEY ON KEYBOARD / INTERNET-CONTROL (Windows 2000 or later)

键盘上的 167 浏览器前进键/互联网控制(Windows 2000 或更高版本)

168 BROWSER REFRESH KEY ON KEYBOARD / INTERNET-CONTROL (Windows 2000 or later)

168 键盘上的浏览器刷新键/互联网控制(Windows 2000 或更高版本)

169 BROWSER STOP KEY ON KEYBOARD / INTERNET-CONTROL (Windows 2000 or later)

169 键盘上的浏览器停止键/互联网控制(Windows 2000 或更高版本)

170 BROWSER SEARCH KEY ON KEYBOARD / INTERNET-CONTROL (Windows 2000 or later)

170 键盘上的浏览器搜索键/互联网控制(Windows 2000 或更高版本)

171 BROWSER FAVORITES KEY ON KEYBOARD / INTERNET-CONTROL (Windows 2000 or later)

键盘上的 171 个浏览器收藏夹/互联网控制键(Windows 2000 或更高版本)

172 BROWSER HOME KEY ON KEYBOARD / INTERNET-CONTROL (Windows 2000 or later)

172 键盘上的浏览器主页键/互联网控制(Windows 2000 或更高版本)

173 MUTE KEY ON KEYBOARD / MEDIA-CONTROL (Windows 2000 or later)

173 键盘上的静音键/媒体控制(Windows 2000 或更高版本)

174 VOLUME DOWN KEY ON KEYBOARD / MEDIA-CONTROL (Windows 2000 or later)

174 键盘/媒体控制上的音量减小键(Windows 2000 或更高版本)

175 VOLUME UP KEY ON KEYBOARD / MEDIA-CONTROL (Windows 2000 or later)

175 键盘上的音量增大键/媒体控制(Windows 2000 或更高版本)

176 The media next track key (Windows 2000 or later)

176 媒体下一曲目键(Windows 2000 或更高版本)

177 The media previous track key (Windows 2000 or later)

177 媒体上一曲目键(Windows 2000 或更高版本)

178 The media Stop key (Windows 2000 or later)

178 媒体停止键(Windows 2000 或更高版本)

179 The media play pause key (Windows 2000 or later)

179 媒体播放暂停键(Windows 2000 或更高版本)

180 The launch mail key / E-MAIL KEY ON KEYBOARD / INTERNET-CONTROL (Windows 2000 or later)

180 启动邮件键 / 键盘上的电子邮件键 / INTERNET-CONTROL(Windows 2000 或更高版本)

181 The select media key / MEDIA KEY ON KEYBOARD / MEDIA-CONTROL (Windows 2000 or later)

181 选择媒体键 / MEDIA KEY ON KEYBOARD / MEDIA-CONTROL(Windows 2000 或更高版本)

182 The start application one key (Windows 2000 or later)

182 一键启动应用程序(Windows 2000或更高版本)

183 The start application two key (Windows 2000 or later)

183 启动应用程序二键(Windows 2000 或更高版本)

184 Reserved

184 保留

185 Reserved

185 保留

186 ; and : KEY

186; 和:键

187 =/+ KEY ON KEYBOARD (above letters)

187 =/+ 键盘上的按键(字母上方)

188 , and < KEY

第188话

189 -/_ KEY ON KEYBOARD (above letters)

189 -/_ 键盘上的键(字母上方)

190 . and > KEY

190 . 和 > 键

191 / and ? KEY

191 / 和?钥匙

192 ~ and ` KEY ON KEYBOARD

第192话

193 Reserved

193 保留

194 Reserved

194 保留

195 Reserved

195 保留

196 Reserved

196 保留

197 Reserved

197 保留

198 Reserved

198 保留

199 Reserved

199 保留

200 Reserved

200 保留

201 Reserved

201 保留

202 Reserved

202 保留

203 Reserved

203 保留

204 Reserved

204 保留

205 Reserved

205 保留

206 Reserved

206 保留

207 Reserved

207 保留

208 Reserved

208 保留

209 Reserved

209 保留

210 Reserved

210 保留

211 Reserved

211 保留

212 Reserved

212 保留

213 Reserved

213 保留

214 Reserved

214 保留

215 Reserved

215 保留

216 Unassigned

216 未分配

217 Unassigned

217 未分配

218 Unassigned

218 未分配

219 [ and { KEY

第219话

220 \ and | KEY

220 \ 和 | 钥匙

221 ] and } KEY

第221话

222 ' and # KEY

222 ' 和 # 键

223 Used for miscellaneous characters; it can vary by keyboard

223 用于杂字符;它可以因键盘而异

224 Reserved

224 保留

225 OEM specific

225 OEM 专用

226 The OEM angle bracket or backslash key on the RT 102 key keyboard (Windows 2000 or later)

226 RT 102 键键盘上的 OEM 尖括号或反斜杠键(Windows 2000 或更高版本)

227 OEM specific

227 OEM 专用

228 OEM specific

228 OEM 专用

229 The PROCESS KEY key (IME PROCESS KEY)

229 进程密钥键(IME PROCESS KEY)

230 Oem specific

230 Oem 特定

231 Used to pass Unicode characters as if they were keystrokes (Windows 2000 or later)

231 用于传递 Unicode 字符,就好像它们是击键一样(Windows 2000 或更高版本)

232 Unassigned

232 未分配

233 OEM specific

233 OEM 专用

234 OEM specific

234 OEM 专用

235 OEM specific

235 OEM 专用

236 OEM specific

236 OEM 专用

237 OEM specific

237 OEM 专用

238 OEM specific

238 OEM 专用

239 OEM specific

239 OEM 专用

240 OEM specific

240 OEM 专用

241 OEM specific

241 OEM 专用

242 OEM specific

242 OEM 专用

243 OEM specific

243 OEM 专用

244 OEM specific

244 OEM 专用

245 OEM specific

245 OEM 专用

246 The ATTN key

第246回

247 The CRSEL key

247 CRSEL键

248 The EXSEL key

248 EXSEL键

249 The ERASE EOF key

249 ERASE EOF键

250 The PLAY key

250 播放键

251 The ZOOM key

251 缩放键

252 Reserved for future use

252 保留以备将来使用

253 The PA1 key

253 PA1键

254 The CLEAR key

254 清除键

255 OTHER / MISC KEY ON KEYBOARD

255 其他/键盘上的其他键

回答by Dmitry Bychenko

Print out a simple report:

打印一个简单的报告

  String report = String.Join(Environment.NewLine, Enum
    .GetValues(typeof(Keys))
    .OfType<Keys>()
    .Select(key => String.Format("{0,6} : {1}", (int) key, key)));

  Console.Write(report);

And you'll get

你会得到

     0 : None
     1 : LButton
     2 : RButton
     3 : Cancel
     4 : MButton
     5 : XButton1
     6 : XButton2
     8 : Back
     9 : Tab
     ....
    65 : A
    66 : B
    67 : C
    68 : D
    69 : E
    ....
   252 : NoName
   253 : Pa1
   254 : OemClear
 65535 : KeyCode
 65536 : Shift
131072 : Control
262144 : Alt
-65536 : Modifiers

Please, have a note, that somekey codes (e.g. 'A'..'Z') correspondto their ASCII values. However, keyboard's keyand characterare differentthings (what if you have some exotic keyboard layout?) so do not relyon this correspondence:

请注意,某些键码(例如'A'..'Z'对应于它们的ASCII 值。然而,键盘的键字符不同的东西(如果你有一些异国情调的键盘布局怎么?)所以不要依赖这种对应关系:

 // If key "F" is downed
 if ((e.KeyCode == Keys.F) && (e.Modifiers == Keys.None)) {
   // Actual character can well be 'А' (on my workstation - Russian layout)
   ...
 }

回答by Leonid Malyshev