入力イベントで起こるタイミングと条件について調べてみた。
○…イベントが発生する。
×…イベントが発生しない。
inputMethodに関してはgetCommittedCharacterCount() 参照。
イベント名\入力文字 |
半角文字やbackspace |
Enter |
変換を確定するときに押すEnter |
全角入力中 |
Ctrl等 |
KeyPressed |
○ |
○ |
× |
× |
○ |
KeyTyped |
○ |
○ |
× |
× |
Ctrl+C or Ctrl+Vのみ |
KeyReleased |
○ |
○ |
○ |
○ |
○ |
inputMethod |
× |
× |
× |
○ |
× |
- 変換確定のEnterではActionEventが発生しない。
- 文字確定後にイベント呼び出しを行いたい時には、inputMethodListenerのinputMethodTextChangedで
getCommittedCharacterCount()から確定された文字が1文字以上であったケースに
何らかのイベントを呼び出せば良い。
- ActionPerformedよりMousePressの方が優先度が高いようだ。
- CtrlやShiftキーはClassクラスのgetModifiers()等やInputEventクラスにisControlDown()といった関数が用意されている。
最終更新:2011年04月02日 13:54