Ctrl remap question

how key remap options works, and where can i find actual docs on it?

I remap CapsLock to be an aditional Ctrl key. On some machines it works fine, others have problems on things like firefox:

On firefox, if i type “kde” in the address bar and press ctrl+enter, i get “h__ps://www.kde.com” (lame, i know)… but if i press capsLock+enter, it just register the return key and tries to load “h__ps://kde” alone

when i run xev on those machines, i see that capsLock register as Caps Lock indeed! but it does behave as L_Ctrl on most programs (only kde and maybe vnc clients i see it as caps lock). What is responsible for translating that to Ctrl if X sees it as caps lock?!?! i’m actually more confused on why it works :slight_smile:

Investigating this, the bad machines have
Settings > Input devices > keyboard > Advanced > Caps Lock Behavior > Make Caps Lock and aditional Ctrl

while the “good” machines have
Settings > Input devices > keyboard > Advanced > Ctrl Position > Caps Lock as Ctrl

I tried following the links on the help for the advanced tab, but it only sends me to XKeyboardConfig

PS: h__ps used instead of https because lame new user restrict number of urls.

If you look at /usr/share/X11/xkb/symbols/capslock, ctrl_modifier does:

// This changes the <CAPS> key to become a Control modifier,
// but it will still produce the Caps_Lock keysym.
hidden partial modifier_keys
xkb_symbols "ctrl_modifier" {
    replace key <CAPS> {
        type[Group1] = "ONE_LEVEL",
        symbols[Group1] = [ Caps_Lock ],
        actions[Group1] = [ SetMods(modifiers=Control) ]
    };
    modifier_map Control { <CAPS> };
};

while looking at /usr/share/X11/xkb/symbols/ctrl, nocaps does:

// Eliminate CapsLock, making it another Ctrl.
partial modifier_keys
xkb_symbols "nocaps" {
    replace key <CAPS> { [ Control_L, Control_L ] };
    modifier_map  Control { <CAPS>, <LCTL> };
};

So, ctrl:nocaps makes CapsLock into an additional Ctrl key, including both activating the Control modifier when it’s pressed, and sending the Control_L keysym in both level 1 and level 2 (when Shift is pressed), while caps:ctrl_modifier just makes CapsLock activate the Control modifier when it’s pressed, while still sending the Caps_Lock keysym.

In the latter case, programs which look at modifiers when a key is pressed will work as you expect, while programs that just look at keysyms, and keep their own internal modifier state will not.

1 Like

oh that’s a very important distinction. i might send a patch later this month with some better text to these options.

thanks for all the details

So I went ahead and opened an issue and MR in xkeyboard-config to improve the description of caps:ctrl_modifier. See:

1 Like