I'd like to configure XKB to use Caps Lock as a way of producing different keys, but I don't want it to appear as a modifier. For example:

  • F1 produces F21 keypress
  • Caps Lock + F1 produces F1 keypress (i.e. no modifiers)
  • Shift + Caps Lock + F1 produces Shift + F1 keypress (only Shift counts as a modifier)

I have partially succeeded with this by assigning Caps Lock to Hyper_R, but the problem is this only works if Hyper_R is also set as a modifier, e.g. Mod3. This means Shift + Caps Lock + F1 actually produces Shift + Mod3 + F1 so any hotkeys listening for Shift + F1 don't work because they don't like Mod3 being present.

Is there any way I can use Caps Lock to change they behaviour of certain keys, without actually having it appear to an X application as a modifier key?

The docs I have read hint that this is possible with advanced XKB configuration but I can't find any details.

1 Answer 1


Sorry, this is ancient, but perhaps even if it's too late for you, someone else may find this hint useful:

In your types, add:

type "CapsShiftSpecial" {
    modifiers= Shift+Hyper;

    map[Shift]= Level2;
    preserve[Shift]= Shift;

    map[Hyper]= Level3;

    map[Shift+Hyper]= Level4;
    preserve[Shift+Hyper]= Shift;

    level_name[Level1]= "Base";
    level_name[Level2]= "Shift";
    level_name[Level3]= "Hyper";
    level_name[Level4]= "Shift Hyper";

Then, in the symbols file, have something like

key <FK01>  { type[group1]="CapsShiftSpecial",
              symbols[group1]=[ F21, F21, F1, F1 ]};

A program monitoring the keystrokes (xev or emacs, for example) will see the keypresses as though you pressed F21, Shift+F21, F1, and Shift+F1.

  • Thanks - for all the things I'd read, this is the first time I understand what preserve can do!
    – Malvineous
    Jun 25, 2015 at 7:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .