Score:1

I swapped Escape and Caps Lock with xkb symbols, but now the Caps Lock key activates both Escape and Caps Lock

in flag

I am working on my own custom keyboard layout and part of that is swapping the Caps Lock and escape keys. The layout appears to work quite well all other keys appear to be remapped correctly, except when I press the physical Caps Lock key on my keyboard it activates escape as expected. But also toggles Caps Lock at the same time.

Pressing the physical Escape just activates Caps Lock. I was hoping I could get the physical Caps Lock key to just activate Escape.

I tried using a different keyboard to see if it was a quirk of my laptop, the problem still persists, also pressing Caps Lock in xev reveals this:

KeyPress event, serial 34, synthetic NO, window 0x1800001,
    root 0x236, subw 0x0, time 680957, (77,65), root:(299,279),
    state 0x2000, keycode 66 (keysym 0xff1b, Escape), same_screen YES,
    XKeysymToKeycode returns keycode: 9
    XLookupString gives 1 bytes: (1b) "
mbLookupString gives 1 bytes: (1b) "
FilterEvent returns: False

Here is my file in /usr/share/X11/xkb/symbols

// based on a keyboard map from an 'xkb/symbols/de' file

default
xkb_symbols "basic" {

    include "latin(type4)"

    name[Group1]="Coding";
    
    // Escape
    key <ESC> {[Caps_Lock]};
    
    // Function keys
    key <FK01> {[F1]};
    key <FK02> {[F2]};
    key <FK03> {[F3]};
    key <FK04> {[F4]};
    key <FK05> {[F5]};
    key <FK06> {[F6]};
    key <FK07> {[F7]};
    key <FK08> {[F8]};
    key <FK09> {[F9]};
    key <FK10> {[F10]};
    key <FK11> {[F11]};
    key <FK12> {[F12]};

    // First row (numbers/symbols)
    key <TLDE> {[bar, ampersand]};
    key <AE01> {[exclam, 1]};
    key <AE02> {[numbersign, 2]};
    key <AE03> {[plus, 3]};
    key <AE04> {[minus, 4]};
    key <AE05> {[underscore, 5]};
    key <AE06> {[equal, 6]};
    key <AE07> {[parenleft, 7]};
    key <AE08> {[braceleft, 8]};
    key <AE09> {[bracketleft, 9]};
    key <AE10> {[less, 0]};
    key <AE11> {[parenright, braceright]};
    key <AE12> {[bracketright, greater]};
    key <BKSP> {[BackSpace]};
    
    // Second row
    key <TAB> {[grave, question]};
    key <AD01> {[v, V]};
    key <AD02> {[k, K]};
    key <AD03> {[y, Y]};
    key <AD04> {[Tab]};
    key <AD05> {[f, F]};
    key <AD06> {[g, G]};
    key <AD07> {[period, comma]};
    key <AD08> {[b, B]};
    key <AD09> {[o, O]};
    key <AD10> {[apostrophe, quotedbl]};
    key <AD11> {[percent, asterisk]};
    key <AD12> {[asciitilde, at]};
    
    // Third Row
    key <CAPS> {[Escape]};
    key <AC01> {[r, R]};
    key <AC02> {[n, N]};
    key <AC03> {[i, I]};
    key <AC04> {[e, E]};
    key <AC05> {[u, U]};
    key <AC06> {[l, L]};
    key <AC07> {[t, T]};
    key <AC08> {[a, A]};
    key <AC09> {[o, O]};
    key <AC10> {[s, S]};
    key <AC11> {[colon, semicolon]};
    key <RTRN> {[Return]};
    
    // Fourth row
    key <LFSH> {[Shift_L]};
    key <AB01> {[z, Z]};
    key <AB02> {[w, W]};
    key <AB03> {[c, C]};
    key <AB04> {[h, H]};
    key <AB05> {[d, D]};
    key <AB06> {[m, M]};
    key <AB07> {[p, P]};
    key <AB08> {[x, X]};
    key <AB09> {[j, J]};
    key <AB10> {[backslash, slash]};
    key <RTSH> {[Shift_R]};

    include "kpdl(comma)"
    include "level3(ralt_switch)"
};

How can I fix this? I need to get this to work for wayland. Which it does, but I doubt any xmodmap solutions will work. Thank you for any help.

Score:0
uz flag

There is an XKB option for doing that. For instance you can set it in the /etc/default/keyboard file:

XKBOPTIONS="caps:swapescape"

So I'd suggest that you try that and drop the related part in the symbols file.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.