Java键盘密钥代码列表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java键盘密钥代码列表相关的知识,希望对你有一定的参考价值。

任何人都可以为我提供键盘上用于Java中KeyEvent类的各个键的键码整数列表吗?

我想创建一个供用户选择的所有键盘键的下拉列表。我需要特定于键盘的列表。在这种情况下,VK常量没有帮助,因为我需要键盘上使用的键的“列表”。 This post here没有使用,因为它适用于javascript,并且与javadoc相比,所有键的代码都不相同。 javadoc中使用的KeyCode值也按字母顺序排列,因此很难在那里找到键盘键。我尝试使用Google搜索来源,但没有任何有趣的内容只出现在Javascript中。我应该自己一个一个地编译它们还是有更简单的方法?

编辑:我知道VK。我需要使用KeyEvent.getKeyText函数在下拉菜单中存储每个键盘键。所以我需要清单。这就是为什么我问我是否需要自己编译它们。我应该早点提到。每个密钥都是浪费时间。

答案

KeyEvent类具有带这些值的静态字段。

例如,KeyEvent.VK_A代表“A”键。

要获取字段名称,您可以使用反射:

Field[] fields = java.awt.event.KeyEvent.class.getDeclaredFields();
for (Field f : fields) {
    if (Modifier.isStatic(f.getModifiers())) {
        System.out.println(f.getName());
    } 
}
另一答案

这是你的清单:

0 - Unknown keyCode: 0x0

1 - Unknown keyCode: 0x1

2 - Unknown keyCode: 0x2

3 - Cancel

4 - Unknown keyCode: 0x4

5 - Unknown keyCode: 0x5

6 - Unknown keyCode: 0x6

7 - Unknown keyCode: 0x7

8 - Backspace

9 - Tab

10 - Enter

11 - Unknown keyCode: 0xb

12 - Clear

13 - Unknown keyCode: 0xd

14 - Unknown keyCode: 0xe

15 - Unknown keyCode: 0xf

16 - Shift

17 - Ctrl

18 - Alt

19 - Pause

20 - Caps Lock

21 - Kana

22 - Unknown keyCode: 0x16

23 - Unknown keyCode: 0x17

24 - Final

25 - Kanji

26 - Unknown keyCode: 0x1a

27 - Escape

28 - Convert

29 - No Convert

30 - Accept

31 - Mode Change

32 - Space

33 - Page Up

34 - Page Down

35 - End

36 - Home

37 - Left

38 - Up

39 - Right

40 - Down

41 - Unknown keyCode: 0x29

42 - Unknown keyCode: 0x2a

43 - Unknown keyCode: 0x2b

44 - Comma

45 - Minus

46 - Period

47 - Slash

48 - 0

49 - 1

50 - 2

51 - 3

52 - 4

53 - 5

54 - 6

55 - 7

56 - 8

57 - 9

58 - Unknown keyCode: 0x3a

59 - Semicolon

60 - Unknown keyCode: 0x3c

61 - Equals

62 - Unknown keyCode: 0x3e

63 - Unknown keyCode: 0x3f

64 - Unknown keyCode: 0x40

65 - A

66 - B

67 - C

68 - D

69 - E

70 - F

71 - G

72 - H

73 - I

74 - J

75 - K

76 - L

77 - M

78 - N

79 - O

80 - P

81 - Q

82 - R

83 - S

84 - T

85 - U

86 - V

87 - W

88 - X

89 - Y

90 - Z

91 - Open Bracket

92 - Back Slash

93 - Close Bracket

94 - Unknown keyCode: 0x5e

95 - Unknown keyCode: 0x5f

96 - NumPad-0

97 - NumPad-1

98 - NumPad-2

99 - NumPad-3

100 - NumPad-4

101 - NumPad-5

102 - NumPad-6

103 - NumPad-7

104 - NumPad-8

105 - NumPad-9

106 - NumPad *

107 - NumPad +

108 - NumPad ,

109 - NumPad -

110 - NumPad .

111 - NumPad /

112 - F1

113 - F2

114 - F3

115 - F4

116 - F5

117 - F6

118 - F7

119 - F8

120 - F9

121 - F10

122 - F11

123 - F12

124 - Unknown keyCode: 0x7c

125 - Unknown keyCode: 0x7d

126 - Unknown keyCode: 0x7e

127 - Delete

128 - Dead Grave

129 - Dead Acute

130 - Dead Circumflex

131 - Dead Tilde

132 - Dead Macron

133 - Dead Breve

134 - Dead Above Dot

135 - Dead Diaeresis

136 - Dead Above Ring

137 - Dead Double Acute

138 - Dead Caron

139 - Dead Cedilla

140 - Dead Ogonek

141 - Dead Iota

142 - Dead Voiced Sound

143 - Dead Semivoiced Sound

144 - Num Lock

145 - Scroll Lock

146 - Unknown keyCode: 0x92

147 - Unknown keyCode: 0x93

148 - Unknown keyCode: 0x94

149 - Unknown keyCode: 0x95

150 - Ampersand

151 - Asterisk

152 - Double Quote

153 - Less

154 - Print Screen

155 - Insert

156 - Help

157 - Meta

158 - Unknown keyCode: 0x9e

159 - Unknown keyCode: 0x9f

160 - Greater

161 - Left Brace

162 - Right Brace

163 - Unknown keyCode: 0xa3

164 - Unknown keyCode: 0xa4

165 - Unknown keyCode: 0xa5

166 - Unknown keyCode: 0xa6

167 - Unknown keyCode: 0xa7

168 - Unknown keyCode: 0xa8

169 - Unknown keyCode: 0xa9

170 - Unknown keyCode: 0xaa

171 - Unknown keyCode: 0xab

172 - Unknown keyCode: 0xac

173 - Unknown keyCode: 0xad

174 - Unknown keyCode: 0xae

175 - Unknown keyCode: 0xaf

176 - Unknown keyCode: 0xb0

177 - Unknown keyCode: 0xb1

178 - Unknown keyCode: 0xb2

179 - Unknown keyCode: 0xb3

180 - Unknown keyCode: 0xb4

181 - Unknown keyCode: 0xb5

182 - Unknown keyCode: 0xb6

183 - Unknown keyCode: 0xb7

184 - Unknown keyCode: 0xb8

185 - Unknown keyCode: 0xb9

186 - Unknown keyCode: 0xba

187 - Unknown keyCode: 0xbb

188 - Unknown keyCode: 0xbc

189 - Unknown keyCode: 0xbd

190 - Unknown keyCode: 0xbe

191 - Unknown keyCode: 0xbf

192 - Back Quote

193 - Unknown keyCode: 0xc1

194 - Unknown keyCode: 0xc2

195 - Unknown keyCode: 0xc3

196 - Unknown keyCode: 0xc4

197 - Unknown keyCode: 0xc5

198 - Unknown keyCode: 0xc6

199 - Unknown keyCode: 0xc7

200 - Unknown keyCode: 0xc8

201 - Unknown keyCode: 0xc9

202 - Unknown keyCode: 0xca

203 - Unknown keyCode: 0xcb

204 - Unknown keyCode: 0xcc

205 - Unknown keyCode: 0xcd

206 - Unknown keyCode: 0xce

207 - Unknown keyCode: 0xcf

208 - Unknown keyCode: 0xd0

209 - Unknown keyCode: 0xd1

210 - Unknown keyCode: 0xd2

211 - Unknown keyCode: 0xd3

212 - Unknown keyCode: 0xd4

213 - Unknown keyCode: 0xd5

214 - Unknown keyCode: 0xd6

215 - Unknown keyCode: 0xd7

216 - Unknown keyCode: 0xd8

217 - Unknown keyCode: 0xd9

218 - Unknown keyCode: 0xda

219 - Unknown keyCode: 0xdb

220 - Unknown keyCode: 0xdc

221 - Unknown keyCode: 0xdd

222 - Quote

223 - Unknown keyCode: 0xdf

224 - Up

225 - Down

226 - Left

227 - Right

228 - Unknown keyCode: 0xe4

229 - Unknown keyCode: 0xe5

230 - Unknown keyCode: 0xe6

231 - Unknown keyCode: 0xe7

232 - Unknown keyCode: 0xe8

233 - Unknown keyCode: 0xe9

234 - Unknown keyCode: 0xea

235 - Unknown keyCode: 0xeb

236 - Unknown keyCode: 0xec

237 - Unknown keyCode: 0xed

238 - Unknown keyCode: 0xee

239 - Unknown keyCode: 0xef

240 - Alphanumeric

241 - Katakana

242 - Hiragana

243 - Full-Width

244 - Half-Width

245 - Roman Characters

246 - Unknown keyCode: 0xf6

247 - Unknown keyCode: 0xf7

248 - Unknown keyCode: 0xf8

249 - Unknown keyCode: 0xf9

250 - Unknown keyCode: 0xfa

251 - Unknown keyCode: 0xfb

252 - Unknown keyCode: 0xfc

253 - Unknown keyCode: 0xfd

254 - Unknown keyCode: 0xfe

255 - Unknown keyCode: 0xff

256 - All Candidates

257 - Previous Candidate

258 - Code Input

259 - Japanese Katakana

260 - Japanese Hiragana

261 - Japanese Roman

262 - Kana Lock

263 - Input Method On/Off

264 - Unknown keyCode: 0x108

265 - Unknown keyCode: 0x109

266 - Unknown keyCode: 0x10a

267 - Unknown keyCode: 0x10b

268 - Unknown keyCode: 0x10c

269 - Unknown keyCode: 0x10d

270 - Unknown keyCode: 0x10e

271 - Unknown keyCode: 0x10f

272 - Unknown keyCode: 0x110

273 - Unknown keyCode: 0x111

274 - Unknown keyCode: 0x112

275 - Unknown keyCode: 0x113

276 - Unknown keyCode: 0x114

277 - Unknown keyCode: 0x115

278 - Unknown keyCode: 0x116

279 - Unknown keyCode: 0x117

280 - Unknown keyCode: 0x118

281 - Unknown keyCode: 0x119

282 - Unknown keyCode: 0x11a

283 - Unknown keyCode: 0x11b

284 - Unknown keyCode: 0x11c

285 - Unknown keyCode: 0x11d

286 - Unknown keyCode: 0x11e

287 - Unknown keyCode: 0x11f

288 - Unknown keyCode: 0x120

289 - Unknown keyCode: 0x121

290 - Unknown keyCode: 0x122

291 - Unknown keyCode: 0x123

292 - Unknown keyCode: 0x124

293 - Unknown keyCode: 0x125

294 - Unknown keyCode: 0x126

295 - Unknown keyCode: 0x127

296 - Unknown keyCode: 0x128

297 - Unknown keyCode: 0x129

298 - Unknown keyCode: 0x12a

299 - Unknown keyCode: 0x12b

300 - Unknown keyCode: 0x12c

301 - Unknown keyCode: 0x12d

302 - Unknown keyCode: 0x12e

303 - Unknown keyCode: 0x12f

304 - Unknown keyCode: 0x130

305 - Unknown keyCode: 0x131

306 - Unknown keyCode: 0x132

307 - Unknown keyCode: 0x133

308 - Unknown keyCode: 0x134

309 - Unknown keyCode: 0x135

310 - Unknown keyCode: 0x136

311 - Unknown keyCode: 0x137

312 - Unknown keyCode: 0x138

313 - Unknown keyCode: 0x139

314 - Unknown keyCode: 0x13a

315 - Unknown keyCode: 0x13b

316 - Unknown keyCode: 0x13c

317 - Unknown keyCode: 0x13d

318 - Unknown keyCode: 0x13e

319 - Unknown keyCode: 0x13f

320 - Unknown keyCode: 0x140

321 - Unknown keyCode: 0x141

322 - Unknown keyCode: 0x142

323 - Unknown keyCode: 0x143

324 - Unknown keyCode: 0x144

325 - Unknown keyCode: 0x145

326 - Unknown keyCode: 0x146

327 - Unknown keyCode: 0x147

328 - Unknown keyCode: 0x148

329 - Unknown keyCode: 0x149

330 - Unknown keyCode: 0x14a

331 - Unknown keyCode: 0x14b

332 - Unknown keyCode: 0x14c

333 - Unknown keyCode: 0x14d

334 - Unknown keyCode: 0x14e

335 - Unknown keyCode: 0x14f

336 

以上是关于Java键盘密钥代码列表的主要内容,如果未能解决你的问题,请参考以下文章

在片段替换上显示/隐藏 Android 软键盘

如何在片段中使用 GetJsonFromUrlTask​​.java

android键盘弹出问题

片段 A 的列表视图中的片段 B 中的新列表视图,单击 A 的列表项

java /对于片段显示键盘:

由于未找到 ID 错误的视图,列表片段未出现