对象(KeyEvent 键)到字符串 (Java)
我有类似以下内容: 值为 KeyEvent.VK_G
的对象。 如何从该对象获取密钥字母(作为字符串
)?
I have something similar to the following:
An object with the value of KeyEvent.VK_G
.
How can I get the key letter from that object (as a String
)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过使用
KeyEvent.getKeyChar()
(请参阅 http://download.oracle.com/javase/6/docs/api/java/awt/event/KeyEvent.html#getKeyChar())。By using
KeyEvent.getKeyChar()
(see http://download.oracle.com/javase/6/docs/api/java/awt/event/KeyEvent.html#getKeyChar()).这是你想做的吗?
在这种情况下将给出“G”。
Is this what you want to do?
Which would give "G" in this case.