The i3 FAQ has migrated to All content here is read-only.
Ask Your Question

Using Caps Lock as mod key

asked 2012-09-13 23:41:32 +0000

SuprDewd gravatar image

I would like to use Caps Lock as my mod key. The only reference to Caps Lock I can find is in the User Guide:

Unlike other window managers, i3 can use Mode_switch as a modifier. This allows you to remap capslock (for example) to Mode_switch and use it for both: typing umlauts or special characters and having some comfortably reachable key bindings. For example, when typing, capslock+1 or capslock+2 for switching workspaces is totally convenient. Try it :-).

But I still don't understand how it can be accomplished. So how can I do it?

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2012-09-13 23:49:48 +0000

moemoe gravatar image
> cat .Xmodmap
clear Lock 
keycode 66 = Hyper_L
add mod4 = Hyper_L

then run

 xmodmap ~/.Xmodmap

and use mod4 in your config

edit flag offensive delete link more


Thanks! Works perfectly.

SuprDewd gravatar imageSuprDewd ( 2012-09-13 23:54:02 +0000 )edit

answered 2012-09-14 00:34:52 +0000

loblik gravatar image

It has been already answered but just to be more clear. There is a table in Xorg which contains mappings between keycodes (what keyboard generates) and keysyms (what you see on screen). And this table can be edited by utility called xmodmap.

For example i have switched Escape and CapsLock to make life easier in vim and other vim-like apps.

At first write desired keymap changes to a file.


remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock

And load that file via xmodmap every time you start X.


# load custom map
xmodmap ~/.xmodmap
edit flag offensive delete link more

answered 2012-09-26 19:06:35 +0000

jney gravatar image

updated 2012-09-27 15:01:36 +0000

I just need some more precision. I'd like Cap Locks key to be the only one modifier. I set Cap Locks as Alt_R (i don't have any right ALT on my laptop). Here is ~/.Xmodmap file :

clear Lock
clear Mod4
keycode 66 = Alt_R
add Mod4 = Alt_R

the xmodmap config is :

# xmodmap -pm
xmodmap:  up to 2 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod4        Alt_R (0x42)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

Now, Cap Locks works, but Win keys still works too..

Is there a way to accomplish it ?

edit flag offensive delete link more

Question Tools


Asked: 2012-09-13 23:41:32 +0000

Seen: 5,325 times

Last updated: Oct 21 '12