I use an alternative keyboard layout that uses CapsLock and # as ISO_Level3_Shift modifiers.

setxkbmap de koy

I also like using CapsLock as additional Escape key when it's just tapped. This can be easily reached by:

xcape -e "ISO_Level3_Shift=Escape"

But this makes both Level3 modifiers act as Escape. How can I apply xcape only to the left modifier key (labeled CapsLock)?


After some reading on the xcape page on github, I found the easy solution. Last year a pull request was merged that allows passing keycodes instead of keysyms to xcape.

The solution is:

xcape -e "#66=Escape"

How to get the right keycode?

xev -event keyboard

Press down the key you want to modify. Then you should see something like that:

KeyPress event, serial 29, synthetic NO, window 0x4c00001,
    root 0x190, subw 0x0, time 771139, (110,626), root:(204,711),
    state 0x0, keycode 66 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
    XKeysymToKeycode returns keycode: 51
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

There you find your keycode (66 in this example).

| improve this answer | |

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.