1

In my customized keyboard layout, I have these lines already:

    // row 1 (E)
    key <TLDE> {    [     question,     exclam,         masculine,      ordfeminine ]   };
    key <AE01> {    [     braceleft,    1                                           ]   };
    key <AE02> {    [     bracketleft,  2,              periodcentered              ]   };
    key <AE03> {    [     parenleft,    3,              EuroSign                    ]   };
    key <AE04> {    [     less,         4                                           ]   };
    key <AE05> {    [     slash,        5                                           ]   };
    key <AE06> {    [     apostrophe,   quotedbl,       dead_diaeresis              ]   };
    key <AE07> {    [     equal,        plus                                        ]   };
    key <AE08> {    [     backslash,    6,              notsign                     ]   };
    key <AE09> {    [     greater,      7                                           ]   };
    key <AE10> {    [     parenright,   8                                           ]   };
    key <AE11> {    [     bracketright, 9,              exclamdown                  ]   };
    key <AE12> {    [     braceright,   0,              questiondown                ]   };

This is the row 1 (the row below Function keys, beyond the letters).

So, for example, now if I press number 1, it will enter {, and when I press shift+1, it will enter 1. It's good. But, when I press Capslock, it enters {, too, but I want 1. Capslock works for letters.

So now, I want to make capslock work for letters AND for this row, but not for the other keys on keyboard like shiftlock, how can I do it?

(Shiftlock: press some keys and release, and you press every key on the keyboard as if Shift is pressed. Not only alphabetical keys, but Insert, Home and arrow keys output will change, which is not what I want)

This is possible in Windows, with Microsoft Keyboard Layout Manager, as there, the key definition contains state of all the 4 levels for one key, and another level for Capslock. But I don't know if xkb allows it.

(cap 1: cap enable on this key, cap 0: not enable)

//SC    VK_     Cap 0   1        2   6   7
//--    ----    ----    ----    ----    ----    ----    ----

02       1      1   1   007b    -1  -1  -1      // DIGIT ONE, LEFT CURLY BRACKET, <none>, <none>, <none>
1

If I understood you correctly, you don't want to change the default behaviour of CAPS LOCK, but only the behaviour of the number row when CAPS LOCK's state is on. In this case you can have among others the following options.

a) Change type by block

Basically use:

  • ALPHABETIC (or #_LEVEL_ALPHABETIC if you wish to have more levels) for those keys which should always be affected by the state of CAPS LOCK.
  • TWO_LEVEL (or THREE_LEVEL, FOUR_LEVEL, etc) for keys which should not be affected by the state of CAPS LOCK, but only by the Shift key.
...
    // row 1 (E)
    key.type[group1]="ALPHABETIC"; <<-----------
    key <TLDE> {    [     question,     exclam,         masculine,      ordfeminine ]   };
    key <AE01> {    [     braceleft,    1                                           ]   };
    key <AE02> {    [     bracketleft,  2,              periodcentered              ]   };
    key <AE03> {    [     parenleft,    3,              EuroSign                    ]   };
    key <AE04> {    [     less,         4                                           ]   };
    key <AE05> {    [     slash,        5                                           ]   };
    ...
    // for further definitions where caps lock should not affect, use the following: 
    key.type[group1]="TWO_LEVEL";
    ... 
...

b) Change each individual key

Here is an example in another context, in case you would prefer to set different key types for each key individually. Basically the key type is set "inside" the key definition, while in the block case it is defined outside and applied on the subsequent key definitions.

partial xkb_symbols "swap_menu_rctrl_print" {
    // for newer thinkpad keyboards with print screen in the wrong place
    key <PRSC> {
        type= "TWO_LEVEL",
        symbols[Group1]= [ Control_R, Menu ]
    };
    key <RCTL> {
        type= "ONE_LEVEL",
        symbols[Group1]= [ Menu ]
    };
};

In general, you can have a look at the definition of a more complex layout such as the German T3 layout define in /usr/share/X11/xkb/de

enter image description here

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.