repeats / SimpleNativeHooks

Java keyboard and mouse event listener library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support more modifiers for NativeKeyEvent

hendriks73 opened this issue · comments

NativeKeyEvent supports left right and unknown "modifiers". Does modifier refer to the shift key? In any case, please also support the other modifier keys, i.e. CTRL, ALT, and on macOS COMMAND.

Thanks.

The modifers are used to disambiguate between different keys on the keyboard that map to the same java.awt.KeyEvent.VK_XXX value.

For example, there are two keys on the standard en-US qwerty keyboards that map to KeyEvent.VK_SHIFT.
image

On OSX, when you press left Shift + X, this will generate two key events:

  1. First key event with KeyEvent.VK_SHIFT and modifier LEFT
  2. Second key event with KeyEvent.VK_X (you don't care about modifer in this case since there is only one X button on the keyboard)

There's a current bug that I cannot distinguish between left command and right command that I'm trying to investigate.
Hope this helps.

Thanks for your explanation!
So for something like ALT-K, I'd have to recognize KeyEvent.VK_ALT and KeyEvent.VK_K. Correct?

That is correct. You'll need to recognize KeyEvent.VK_ALT and KeyEvent.VK_K.

Each key event will also include whether the key is pressed or release, so you can figure out whether the two are pressed as a combination or one after another.