jnativehook icon indicating copy to clipboard operation
jnativehook copied to clipboard

Key Presses not detected in Minecraft on MacOS Monterey 12.2.1

Open LiamKinghouser opened this issue 3 years ago • 4 comments

This issue is only present inside Minecraft

So basically when pressing shift and a num key, the num key is not detected and only the shift key is registered inside Minecraft. This issue only occurs once, and then right after that, it works properly. Then, a bit later, the issue will arise again. I'm wondering if this has to do with some kind of event priority going to jnativehook before Minecraft, but it's just a guess as I've no idea how this project works. Can provide additional info if needed.

LiamKinghouser avatar Apr 01 '22 00:04 LiamKinghouser

I honestly have no idea... I can tell you that the reason you're getting the modifier key and not a normal key is because CGEventTapCreate() returns a kCGEventFlagsChanged event for modifier key presses and this library creates a key down/up event for the change. The same exact event tap created with CGEventTapCreate() that produced that modifier event should also produce kCGEventKeyDown & kCGEventKeyUp events for non-modifier key presses. You can look at the code here.

OS X or Minecraft are doing something wired that is causing the event tap to not work as expected. You could try enabling the debug logs and see if anything interesting comes out, but it is highly unlikely that there is anything I can do about it from the perspective of this library.

kwhat avatar Apr 01 '22 00:04 kwhat

Thanks for the quick response.

I have tried literally everything with the debug logs. I saw a post at one point that recommended setting them all to off to try and see if that would fix the issue, and it did not. When on, no warnings or errors appear. Looks like I do need to update my OS so I'll see if that fixes it.

LiamKinghouser avatar Apr 01 '22 00:04 LiamKinghouser

Set the logs to finest level:

Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.ALL);
logger.setUseParentHandlers(false);

You should see mouse events and key press / release events. Just curious if the key up/down event handler is even being called.

kwhat avatar Apr 01 '22 01:04 kwhat

When enabling the logs, nothing is logged, but the key presses are still detected.

LiamKinghouser avatar Apr 01 '22 03:04 LiamKinghouser