I'm trying to disable Capslock and make the following remaps:

Ctrl+Capslock => Capslock
Alt+Capslock => Escape (since my Escape key is broken)

Right now I'm trying to use Xmodmap.

I have only the following:

keycode 66 = NoSymbol Caps_Lock

This disables Capslock and maps Shift+Capslock to Capslock, but what I want is Ctrl+Capslock instead of Shift+Capslock.

I have no idea how to map Alt+Capslock to the Escape key.

I want to clarify that I don't need an answer to use Xmodmap, any method will be fine.

  • 1
    +1 All my life being frustrated how easy it is to press accidentally CAPS while typing fast only to a sentence later discover that you have to retype everything anew. – Vorac Jul 12 '12 at 15:16
  • Its worse for me, I use vim. Oh the horror! <=O – qtwtetrt Jul 22 '12 at 8:55

Xmodmap cannot do what you're asking for, but it can bring you close.

The basic syntax for modifying the behavior of a key is



  • KEYSYMBOL2 gets triggered when pressing the key while pressing Shift.
  • KEYSYMBOL3 gets triggered when pressing the key while pressing ModeSwitch.
  • KEYSYMBOL4 gets triggered when pressing the key while pressing Shift + ModeSwitch.
  • KEYSYMBOL1 gets triggered when pressing the key with none of the above.
  • ModeSwitch is AltGr by default (only works on some keyboard layouts).

We can't set Ctrl or Alt to be the ModeSwitch key, since no key can serve as two different modifiers.

However, we can turn CapsLock into the ModeSwitch key:

xmodmap -e "keysym Caps_Lock = Mode_switch Mode_switch"

To remap CapsLock + Ctrl to the CapsLock key, execute the following commands.

xmodmap -e "keysym Control_L = Control_L Control_L Caps_Lock"
xmodmap -e "keysym Control_R = Control_R Control_R Caps_Lock"

Note the CapsLock is the modifier key here, so you have to press this key first.

We can't remap CapsLock + Alt or CapsLock + Super to Escape in the same manner, since Alt and Super serve different functions when pressed alone and when used as modifier keys.

Every other key will work fine. Examples:

  • For CapsLock + ` (standard US layout), use

    xmodmap -e "keysym grave = grave asciitilde Escape"
  • For CapsLock + Space, use

    xmodmap -e "keysym space = KP_Space KP_Space Escape"


  • To make the remappings permanent, create/edit the file .gnomerc in your home folder and save the corresponding commands in it.

  • To undo all remappings, simply execute


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.