How to remap the Caps Lock key to Control for Emacs

How to remap the Caps Lock key to Control for Emacs? My left little finger is just so tired…

You can either change it in gnome-tweak-tool on Gnome 3:


You can make use of 2 tools: xev to find out the key code for Caps Lock and xmodmap to modify key maps.

First, run xev in an console and print the Caps Lock. It will print some events, find a line like:

state 0x4, keycode 66 (keysym 0xffe3, ...

The keycode for the Caps Lock is 66.

Then, set the mapping of the Caps Lock with xmodmap to map Caps Lock to left Control:

xmodmap -e "keycode 66 = Control_L"

Last, if you want to save the changes permanently, you may consider add the config into your ~/.xsession file.


You can run xmodmap on this map:

clear control
clear Lock

keycode  66 = Control_L

add control = Control_R Control_L
Answered by Eric Z Ma.

Eric Z Ma

Eric is a father and systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

Leave a Reply

Your email address will not be published. Required fields are marked *