kwhat / jnativehook

Global keyboard and mouse listeners for Java.
Other
1.75k stars 348 forks source link

wrongly generated CTRL_L_MASK #340

Closed Xoriun closed 2 years ago

Xoriun commented 3 years ago

When reading NativeKeyEvents, some of the events carry a CTRL_L_MASK modifier, although I haven't pressed nor released left control since the hook was registered. (Or even after I restarted my pc). Every second NativeKeyEvent is affected, very rarely only every third. Sometimes the masks suddenly disappear. Eg when pressing 'a', 'd', 'a', 'd', 'a', 'd' and so on, every 'd' will come with a CTRL_L_MASK and the 'a' come as expected. Usually the first key works fine. I'm using Windows 10.

kwhat commented 3 years ago

I cannot duplicate this problem with the latest build, but I did notice some interesting behavior with the caps-lock mask. I will investigate further.

kwhat commented 3 years ago

This is so broken upstream by Microsoft I doubt its going to get fixed. They have been screwing around with the SetWindowsHookEx function and they have really screwed it up, now it's totally unreliable. Just try using the caps-lock or num-lock and check out what kind of events you see. Caps-lock will produce anywhere between 1 and 4 events and never the correct mask, and number lock only works once and then just stops producing events. What a disaster.

kwhat commented 2 years ago

I just tested this with the latest nightly and it appears to be working correctly. Please reopen if this problem persists.