keyTyped、keyPressed、keyReleased之间的区别是什么?

xhwang 2005-08-11 09:51:41
有点迷糊,请了解的指点一下,呵呵
谢谢
...全文
4419 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
晨星 2005-08-11
  • 打赏
  • 举报
回复
JavaDoc的KeyEvent类的说明中有详细的描述:

KEY_TYPED
public static final int KEY_TYPED
The "key typed" event. This event is generated when a character is entered. In the simplest case, it is produced by a single key press. Often, however, characters are produced by series of key presses, and the mapping from key pressed events to key typed events may be many-to-one or many-to-many.

See Also:
Constant Field Values

--------------------------------------------------------------------------------

KEY_PRESSED
public static final int KEY_PRESSED
The "key pressed" event. This event is generated when a key is pushed down.

See Also:
Constant Field Values

--------------------------------------------------------------------------------

KEY_RELEASED
public static final int KEY_RELEASED
The "key released" event. This event is generated when a key is let up.

See Also:
Constant Field Values
晨星 2005-08-11
  • 打赏
  • 举报
回复 4
KeyPressed是键被按下,KeyReleased是键被弹起,这两个都是更底层一些的事件。
KeyTypede是指有字符被输入,比如按住shift,再按A键,如果当时Caps Lock不亮,就产生一个输入大写A的事件。

62,636

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧