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'm using Xubuntu 12.04. How do I either swap or remap the Control (or any key) and Caps Lock keys?

share|improve this question

4 Answers 4

Another way:

sudo vi /etc/default/keyboard

then find the line that starts with XKBOPTIONS, and add ctrl:nocaps to make Caps Lock an additional Control key or ctrl:swapcaps to swap Caps Lock and Control.

For example, mine looks like

XKBOPTIONS="lv3:ralt_alt,compose:menu,ctrl:nocaps"

then run

sudo dpkg-reconfigure keyboard-configuration

The reason this way is better is that it will take effect on the virtual consoles (e.g. Ctrl+Alt+F1) as well as in the graphical desktop.

share|improve this answer
1  
This is beautiful; how long has XKBOPTIONS been around for? –  Ehtesh Choudhury Jan 22 at 6:39
2  
XkbOptions is named for a setting in X. The capability is provided by the console-setup package, which seems to have been in Ubuntu since at least Lucid, and probably earlier. –  Mikel Jan 22 at 15:22
    
I like your method, but unfortunately it just isn't working. I even see a new init image generated. –  Evan Carroll Feb 3 at 18:45
2  
Works perfectly on xubuntu 14.04, thank you –  Bjarke Freund-Hansen May 15 at 8:47
1  
Also works flawlessly here on Ubuntu 14.04. –  Doorknob Aug 7 at 7:14

To swap the keys go:

XubuntuSettings ManagerSession and Startup

Then in the Sessions and Startup configurator go

Application Autostart (tab at the top) → Add (bottom button)

Now on the Add Application screen

  • Name: Control and CapsLk swap
  • Description: Swap the two keys
  • Command: /usr/bin/setxkbmap -option "ctrl:swapcaps"

To remap Caps Lock to Control go:

Xubuntu → Settings Manager → Session and Startup

Then in the Sessions and Startup configurator go

Application Autostart (tab at the top) → Add (bottom button)

Now on the Add Application screen

Name: Remap CapsLk to Ctrl
Description: Remap the CapsLk key to Control
Command: /usr/bin/setxkbmap -option "ctrl:nocaps"
share|improve this answer
4  
Wow, that is dramatically harder than it used to be –  foxxtrot Sep 12 '12 at 1:06
    
On my almost fresh Ubuntu 13.10 install, it works when manually executed but not from “Session and Startup”. –  Chris Mar 8 at 9:23

For Raring (at least):

Start "Keyboard layout" (from dash).

Press "Options..." to reach "Keyboard layout options" menu.

I chose "Ctrl key position" => "Caps lock as Ctrl". Your tastes may differ.

share|improve this answer
    
What is "dash"? Surely not Unity (in Xubuntu), I hope. This sounds a lot like the Gnome solution that is unavailable in Xubuntu. –  Marty Fried Jun 7 at 23:42

For compose instead of caps put compose:caps as the -options parameter.

share|improve this answer

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.