How to capture Caps Lock press event while Caps Lock is already on? (CAps LOck DElay GLitch, again...) reddit / BSD ---------------------------------------------------------------------- RetroZvoc · 2019-05-18 20:36 Hello, everybody. I have a serious issue with all UNIX-ish OSes (except Mac computers). When I taptap my Caps Lock key with my pinkyfinger just like everyone else in my town and school who didn't learn how to use Shift for that but only Shift for !"#$%&/()=?\* characters, on Windows, it works normally, but on Linux and, during my escapism from the cancer called GPL and love for MIT/BSD/zlib-png and other free (free as in no strings attached) licenses, I've always got this error: **CAps LOck DElay GLitch.** It happens because Caps Lock on Windows turns on at key press and turns off at key release while on UNIXes, it turns on at key press but it turns off AT KEY RELEASE!!! I've been trying to edit the xkbd script on my own and having to restart my computer due to how broken my system would get (not BSD but any Linux); I broke it so many times in the way that I couldn't type anymore nor use my mouse! BEFORE commenting: 1. DON'T tell me to use Shift! When I use it, my pinky finger won't release it fast enough and I end up with THe SAme PRoblem 2. DON'T tell me I'm using Caps Lock unintendedly because it IS intendedly for Windows! 3. DON'T tell me to use the Caps Lock fixer because even though it fixes THis PRoblem, typing I'm gives me I?m which proves that the fixer is nothing but a lazy bodge that secretly presses Shift while Caps Lock is on and the Caps Lock key is being held. I'm sorry, but I'm a Windows guy running from the political extremism of copyright and copyleft and I need copycenter. I love computers because it has always been my escapism from the real life's father of mine who just keeps yelling about politics. ​ **My thoughts about a solution:** I'm currently running TridentOS in VirtualBox because I don't have enough disk space yet. I plan to make it my main OS because of its promising features, its good and stable performance, its promising BSD license and its promising compatibility with everything I want to use (Godot Engine game development tool, retro game emulators, screen capture, Discord and IM stuff, dividing audio inputs and outputs for Let's Play YouTubing while voice chatting, etc.). I want to make my TridentOS experience amazing. So I was thinking about solving this CAps LOck DElay GLitch by making some script or program that captures keyboard input for Caps Lock key press after the Caps Lock is already on so that I can turn it off manually. My pseudocode looks like this: void MyFunctionThatRunsOnCapsLockKeyPress(Event& event) { if(CapsLockFlagBeforeThisEvent(event)) { CapsLockFlag=false; } } That way, my Caps Lock flag would turn off just as soon as I'd press the Caps Lock key to turn Caps Lock off as I could on Windows. **Question:** Could you please write the code that does this for me? If not, what scripting system I'd need to use to solve this and which functions correspond to my pseudocode to make my idea work? For a scripting system, I don't want to install bloat or commercial stuff or non-copycenter licensed stuff just to implement this. I would like to learn what's already used in TridentOS. ​ **Thank you** for listening to this huge rant and for your patience and time and help. ---------------------------------------------------------------------- enodragon1 · 2019-05-18 22:23 You're beyond help. ---------------------------------------------------------------------- ZueroGuerrero · 2019-05-19 02:40 you might wanna invest in improving your relationship with your father instead ---------------------------------------------------------------------- Kernigh · 2019-05-20 05:24 >It happens because Caps Lock on Windows turns on at key press and turns off at key release while on UNIXes, it turns on at key press but it turns off AT KEY RELEASE!!! This says that Caps Lock on Windows works exactly like Caps Lock on Unix, so I'm not sure how you want to change Unix to be like Windows. You also mention "the Caps Lock fixer", but I don't know what that is. From "DElay GLitch", I guess that you tried to turn off caps lock and type a lowercase letter, but you pressed the caps lock key and typed the letter before you released the caps lock key. Your pseudocode suggests that you want to program the caps lock key to turn off caps lock when you press the key, instead of when you release the key. In Xorg, the [X Keyboard Extension (XKB)](https://www.x.org/wiki/XKB/) handles modifiers like caps lock. The protocol spec uses SA\_LockMods for lock keys (like caps lock, num lock), but SA\_LockMods always turns off the modifier on key release. I didn't find a way to map a key that would turn off a modifier on key press. It might be possible to program an X client to grab the caps lock key, then ask XKB to turn on or off the modifier, almost like the pseudocode. I would write it in C and use the X C Bindings (xcb), but I don't know enough about xcb. ---------------------------------------------------------------------- RetroZvoc · 2019-05-20 07:32 This is what I've been wanting/waiting to hear. Thank you for your comprehensive extensive comment. I release Caps Lock too late, but on Windows, it's not too late because it turns off at press and not at release. I'm glad you caught my idea. Catching Caps Lock release to trigger my function. Now, could you just tell me where I can download this thing? I cannot find a Download button anywhere nor can I find tutorials of this for BSD. ---------------------------------------------------------------------- [deleted] · 2019-05-30 19:14 [deleted] ---------------------------------------------------------------------- manjtemp · 2019-06-07 16:01 Another idea (sorry I'm late to the party) is to use xmodmap to set up a latch key instead of a lock key. While I'm not sure you can do it with caps, you can do it with ISO_Level_3_Latch. It would mean adding capital letters to the ISO_Level_3_Latch bindings in xmodmap. The latch only modifies the next character before disengaging, or if you double tap it, it acts as a lock. It would mean no longer double tapping caps, just a single tap and keep typing. ---------------------------------------------------------------------- RetroZvoc · 2019-06-07 16:52 Wow that's an epic idea! Then it would act like the Android keyboards. But what about the Caps LED? ---------------------------------------------------------------------- manjtemp · 2019-06-07 16:54 If there is a shift/caps latch, then I'd think the led would light up. But if you rebind ISO_Level_3_Latch then I don't think the led will light up. ---------------------------------------------------------------------- RetroZvoc · 2019-06-07 16:58 Is all that non-GPL? ---------------------------------------------------------------------- manjtemp · 2019-06-07 17:16 Its just xmodmap, which iirc uses X11 license ---------------------------------------------------------------------- micrex256 · 2019-08-15 05:11 This is actually a bug exclusive to the X11 [X.Org](https://X.Org) port on Linux (and I presume the x86 BSDs use the same buggy port like Linux). Real UNIX OSes implement their own version of X11 (like AIX, Solaris, Irix) and the capslock key works just fine like it does under Windows and macOS. The problem is that the Linux community seems to think this \*isn't\* a bug and doesn't want to change it for fear of people who are now used to this 'alternative' behaviour of capslock that's different from every other operating system. Peter Hutterer proposed a fix that was turned down in favour of another fix that doesn't still quite solve the issue nor apply automatically, so you could always modify your Linux [X.Org](https://X.Org) with this: [https://patchwork.freedesktop.org/p atch/6538/](https://patchwork.freedesktop.org/patch/6538/) So... Linux \*almost\* had a permanent fix to the issue that was rejected :)