libuiohook icon indicating copy to clipboard operation
libuiohook copied to clipboard

Caps lock can't be suppressed on Mac OS Monterey

Open saml-dev opened this issue 3 years ago • 1 comments

I'm on Mac OS 12.6 and suppressing caps lock doesn't work.

Setup

To test this, I'm building and running the demo_hook example in this repo. I added these lines to try to suppress the event:

        case EVENT_KEY_PRESSED:
           if(event->data.keyboard.keycode == VC_CAPS_LOCK){
                printf("caps lock press: %d\n",event->mask);
                event->reserved = 0x1;
            }
            break;
        case EVENT_KEY_RELEASED:
            if(event->data.keyboard.keycode == VC_CAPS_LOCK){
                printf("caps lock release: %d\n",event->mask);
                event->reserved = 0x1;  //and this part
            }
            break;

Expected Behavior

Setting event->reserved should prevent the caps lock key default behavior from happening.

Actual Behavior

The caps lock press is still registered and toggles the caps lock mode.

Note – I am able to suppress other keys successfully, such as VC_D. Let me know if there's any other testing I can do. I've never written C and was just compiling/tweaking this to test, but happy to help how I can.

saml-dev avatar Sep 24 '22 22:09 saml-dev

It sounds a lot like Apple is intentionally preventing this behavior. The caps-lock key on OSX works a lot differently than most other keys. I am not sure there is any way to "fix" this. Windows does something similar with ctrl+alt+delete.

kwhat avatar May 05 '23 02:05 kwhat