# How to swap caps lock and ctrl without xorg?

## davidshen84

Hi,

I would like to swap the caps lock key and the left ctrl key, as I am a Emacs user. I found several tips on how to do it with X. But I would like to do it even before X stars, so I could use this feature under terminal.

My system is Gentoo 64 bit, with systemd. Any idea how can I achieve that?

Thanks.

----------

## fedeliallalinea

Can help this and this?

----------

## davidshen84

I think the 1st one is talking about terminal under X; and the 2nd is for OpenRC, but I have systemd. I guess there's similar method under systemd, I just have not found it online...

----------

## fedeliallalinea

 *davidshen84 wrote:*   

> I think the 1st one is talking about terminal under X; 

 

No virtual console are not X terminal

 *www.emacswiki.org wrote:*   

> Virtual consoles
> 
> This is not the same as a terminal running in a window under X! It is the text-only mode typically accessed by pressing Ctrl+Alt+F1-F6.

 

 *davidshen84 wrote:*   

> and the 2nd is for OpenRC, but I have systemd. I guess there's similar method under systemd, I just have not found it online...

 

Yes, my fault, but with a simple search in wiki.gentoo.org you can find this (anyway I'm not sure you can set emacs as KEYMAP)

----------

## davidshen84

Thanks, I will try it out.

----------

## davidshen84

I tried to set the keymaps from systemd, and it did changed the caps lock key to function as a ctrl key. However, what I am looking for is to swap the caps lock key and the ctrl key. That is to say, I need the left ctrl key to function as a caps lock key.

I guess I can go deeper and modify the key maps file in the system. But I just have no idea where to look for those files... :Sad: 

----------

## R0b0t1

Editing the layout you use in "/usr/share/kbd/keymaps/" will change the layout for all users. Alternatively you can look at using a program called loadkeys - you may wish to decompress your keymap from the default directory as a starting point, or you may use dumpkeys.

The lines are given as "keycode # = Symbol". Simply switch the place of capslock and left control.

See https://wiki.archlinux.org/index.php/Keyboard_configuration_in_console or search "virtual terminal keyboard layout" or some variation thereof.

----------

## 1clue

Editing the layout as @R0b0t1 said will also erase your change every time you get an update to the appropriate package.

You should be able to store the file elsewhere and get the same results.

----------

