You are not logged in.

#1 2012-10-28 04:50:49

angelfalls
Member
Registered: 2012-03-26
Posts: 139

Remap caps lock to Ctrl in console (tty)

I tried to use loadkeys to remap caps lock to Ctrl and Ctrl to caps lock but it doesn't work, because i think use caps lock is easier than press Ctrl when i move around keyboard. so i wonder:
1. how can i remap caps lock to Ctrl and Ctrl to caps lock in bash (in tty)
2. how can i remap caps lock to ESC in vim (in tty)

I tried to modify /usr/local/share/kbd/keymaps/personal.map

keycode 58 = 29
keycode 29 = 58 

58 is caps lock keycode
29 is control keycode.

Thanks in advanced!

Offline

#2 2012-10-28 05:03:25

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Remap caps lock to Ctrl in console (tty)

Assuming you are using systemd, you should create your custom keymap and link to it from /etc/vconsole.conf, like so:

KEYMAP=/etc/ctrl2escape.kmap

That will be sufficient to remap in your TTY (in Vim and any other apps you run)...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2012-10-28 05:40:41

angelfalls
Member
Registered: 2012-03-26
Posts: 139

Re: Remap caps lock to Ctrl in console (tty)

ctrl2escap is similar with my personal.map?. Can you show me in detail, in my special case? what i need to write in ctrl2escap?

Last edited by angelfalls (2012-10-28 05:42:02)

Offline

#4 2012-10-28 05:45:36

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Remap caps lock to Ctrl in console (tty)

No. There is a wiki article that you can read:
https://wiki.archlinux.org/index.php/KEYMAP


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2012-10-28 06:11:49

angelfalls
Member
Registered: 2012-03-26
Posts: 139

Re: Remap caps lock to Ctrl in console (tty)

That's work, but i mean when i in bash (console) i can use caps lock as left Ctrl so i remap, ok it's work, but when i in vim i want caps lock as Escape, anyway to make this behavior possibly?

Offline

#6 2012-10-28 06:53:42

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Remap caps lock to Ctrl in console (tty)

You are not being very clear: I assume you mean vim in X? As opposed to vim in TTY - because a keymap will work for all apps in the TTY. For applications in X, you want to use setxkbmap.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2012-10-28 06:53:55

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Remap caps lock to Ctrl in console (tty)

Make two keymaps, write a super short script that simply changes keymap before calling vim. 

I think you are not a native speaker, so don't take this the wrong way, but then you way "That's work..." a native speaker might actually parse that as "That is work I don't want to do..."  What I think you actually mean though is "That works..."  I surely hope I am correct on this.

Offline

#8 2012-10-28 07:18:04

angelfalls
Member
Registered: 2012-03-26
Posts: 139

Re: Remap caps lock to Ctrl in console (tty)

yep, tks a lot, english is not my native language.

write a super short script that simply changes keymap before calling vim. 

you mean i need to reload keymap when i call vim. if that i need to modify my .vimrc to call a script to reload the keymap. humm, that's problem, how can i call a script in .vimrc?  i am new to linux so can you show me howto?

Offline

#9 2018-11-12 19:22:55

Vlad3
Member
Registered: 2018-02-02
Posts: 9

Re: Remap caps lock to Ctrl in console (tty)

Hi! This is not a necro-bump, it just is a good thread to post.

I have a problem - I swapped the keycodes and checked it works with showkey. But now when I press CapsLock - it acts like Control but it also locks.

Meaning that I press and release the key and my keyboard acts like Control is still pressed (like CapsLock would normally act). I try to press it again, but it won't unlock Control to go back to normal  behavior. It makes the keyboard unusable.

Any tips?

Offline

#10 2018-11-12 19:40:01

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Remap caps lock to Ctrl in console (tty)

Yes, it is a necrobump. Also your issue is entirely different.


Closing


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB