[Mouse, Keyboard] mouse clicked与 mouse pressed, a key-pressed event, a key-typed event, and a key-released event 的区别

1.
mouse clicked与 mouse pressed 的区别

前者是在同一个位置press和release才触发事件,执行操作. 如果在用户一个位置按下鼠标后改变了主意,则移动到另一个位置(按钮外面)放开就会取消操作(不执行操作).


而后者只是触发press事件, 也就是说按下鼠标就执行操作




2.

The text field fires three events: a key-pressed event, a key-typed event, and a key-released event.
Note :
the key-typed event doesn't have key code information.
key-pressed and key-released events don't have key character information.

用来检验text changed可以用key-released events. 因为它能够通过getText()得到textfield中改变后的text.  而 key-pressed event, key-typed event 得到的是改变前的文字

  • Press and release the Shift key.
    The text field fires two events: a key-pressed and a key-released. The text field doesn't fire a key-typed event because Shift, by itself, doesn't correspond to any character.

     

  • Type an uppercase 'A' by pressing the Shift and A keys.
    You'll see the following events, although perhaps not in this order: key-pressed (Shift), key-pressed (A), key typed ('A'), key-released (A), key-released (Shift). Note that Shift is listed as the modifier key for the key-typed and key-pressed events.

     

  • Type an uppercase 'A' by pressing and releasing the Caps Lock key, and then pressing the A key.
    You should see the following events: key-pressed (Caps Lock), key-pressed (A), key typed ('A'), key-released (A). Note that Caps Lock is not listed as a modifier key.

     

  • Press the Tab key. No Tab key-pressed or key-released events are received by the key event listener. This is because the focus subsystem consumes focus traversal keys, such as Tab and Shift Tab. Press Tab twice more to return the focus to the text area.

     

  • Press a function key, such as F3. You'll see that the function key is an action key.

     

  • Press the left Shift key, followed by the right Shift key. The key-pressed and key-released events indicate which Shift key was typed.

     

  • Press the Num Lock key if your keyboard has a number pad. As for Caps Lock, there is a key-pressed event, but no key-released event.

     

  • Press the '2' key on the number pad. You see the key-pressed, key-typed, and key-released events for the number '2'.

     

  • Press the '2' key on the standard keyboard. Again, you see the three event messages. The key-typed events for both number 2 keys are identical same as press in number pad. But the key-pressed and key-released events indicate different key codes and different key locations.

     

  • Press the Num Lock key again. A key-released event is fired.
  • 你可能感兴趣的:([Mouse, Keyboard] mouse clicked与 mouse pressed, a key-pressed event, a key-typed event, and a key-released event 的区别)