We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5158

Summary: [PATCH] Caps Lock key behaves like a locking key on macOS
Product: SDL Reporter: Cameron Gutman <cameron.gutman>
Component: eventsAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.12   
Hardware: x86   
OS: macOS 10.15   
Attachments: Change Caps Lock to toggle behavior

Description Cameron Gutman 2020-05-26 03:57:28 UTC
I understand macOS provides some unique challenges for recognizing caps lock key presses (see #2157), but https://hg.libsdl.org/SDL/rev/6a3b2cc9d66c introduced a new issue where SDLK_CAPSLOCK behaves like a locking key.

We receive SDL_PRESSED when Caps Lock is toggled on, then an SDL_RELEASED when it is toggled off. This behavior differs from Win32 and X11 where we get a SDL_PRESSED/SDL_RELEASED pair each time the key itself is pressed and released.

There's not a perfect solution for observing the physical state of the Caps Lock key on macOS, but I think toggle behavior more accurately represents how most users use the Caps Lock key than the locking behavior we have today.

If I'm using Caps Lock down to trigger an action in game, the current behavior means that the SDL_PRESSED codepath will only be executed every other time that Caps Lock is pressed.
Comment 1 Cameron Gutman 2020-05-26 03:58:20 UTC
Created attachment 4356 [details]
Change Caps Lock to toggle behavior
Comment 2 Sam Lantinga 2020-05-29 23:08:20 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/bb3d7dcb4ae8