Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to swap the Caps Lock and Escape key as specified in this answer:

Use the keyboard preferences to swap Caps Lock and Escape - seriously, how often do you use Caps Lock? Using vim you will be using Escape all the time, and having it available on the home row makes a huge difference. With the standard Ubuntu desktop, go through the menus: System -> Preferences -> Keyboard -> Layouts tab. Then hit the "Layout Options" button, click on the triangle next to "Caps Lock key behaviour" and select "Swap ESC and CapsLock".

but, I'm using Ubuntu Server with no gui, so how would I do this from the command line?

share|improve this question
    
Did you try following instructions provided at superuser.com/questions/290115/… ? –  Vitalie Ciubotaru Jun 29 '12 at 2:19
    
@VitalieCiubotaru I didn't know that QA existed. I'll be sure to check it out. –  jumpnett Jun 29 '12 at 18:35
    
Please remember to accept/upvote the best answer to your question (tick/check mark on the left). This way, the question is marked as "answered" and future readers can refer to it knowing the solution works. Thank you...:) –  izx Jul 8 '12 at 4:59
    
@izx I will when I test it. Unfortunately, I haven't had time to. –  jumpnett Jul 9 '12 at 15:44

1 Answer 1

Swapping Esc and CapsLock, with combinations, e.g. Ctrl-Esc

  • dumpkeys | grep -P -i "^keymaps.*|^keycode.*escape|^keycode.*lock" > swap.map
  • swap.map should look something like:
    keymaps 0-127
    keycode   1 = Escape
    keycode  58 = CtrlL_Lock
    keycode  69 = Num_Lock
    keycode  70 = Scroll_Lock
    
  • Swap the values of keycodes 1 and 58, while deleting the other _Lock lines; leave the first line intact though.
  • Try it out with sudo loadkeys swap.map
  • Assuming it works, simply add this line to /etc/rc.local, before the exit 0 line, to activate the swap upon boot:
    loadkeys /home/user/swap.map  # or whatever path you chose

See the source for a more general explanation.

share|improve this answer
    
doesn't appear to work over ssh –  Brandon Thomson Nov 3 '12 at 10:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.