简体   繁体   English

Java / AWT / Swing:如何区分按下的回车键或返回键

[英]Java/AWT/Swing: how to distinguish the pressed enter or return key

It looks like native applications behave differently if the user presses the Return key (right to the characters) or the Enter key (number key pad) - one time a new line character is inserted, the other time the default button is activated. 如果用户按下返回键(字符右侧)或Enter键(数字键盘),则本机应用程序的行为会有所不同 - 一次插入新行字符,另一次激活默认按钮。

How I can distinguish both key presses from Java/AWT/Swing? 如何从Java / AWT / Swing中区分出两个按键?

keyEvent.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM