Difference between revisions of "CapsLock Remap Howto"

From Noah.org
Jump to: navigation, search
(X11)
Line 6: Line 6:
  
 
== Windows ==
 
== Windows ==
 +
 
Go here [http://www.microsoft.com/technet/sysinternals/Miscellaneous/Ctrl2Cap.mspx Sysinternals ctrl2cap].
 
Go here [http://www.microsoft.com/technet/sysinternals/Miscellaneous/Ctrl2Cap.mspx Sysinternals ctrl2cap].
  
 
== Linux Console ==
 
== Linux Console ==
  
You just need to remap keycode 58 from "Caps_Lock" to "Control" in your keymap file, then load the keymap using loadkeys.
+
You just need to remap keycode 58 from "Caps_Lock" to "Control" then load using loadkeys. Many Linux distros actually have hooks in place to do this for you. This is the command that will do the trick (run this as root):
  
The keymap files are stored in different places depending on your version of Linux. Just do a locate for "defkeymap". The keyboard maps in Ubuntu are stored here:
+
<pre>
 +
dumpkeys | sed 's/58 = Caps_Lock/58 = Control/' | loadkeys
 +
</pre>
 +
 
 +
I put this in my global alias file:
 +
 
 +
<pre>
 +
alias killcaps='sudo dumpkeys | sed \'s/58 = Caps_Lock/58 = Control/\' | loadkeys'
 +
</pre>
 +
 
 +
Most distros put these types of commands into a keymap file. The keymap files are stored in different places depending on your version of Linux. It is sometimes called "defkeymap" or "remap".
 +
 
 +
=== Newer Ubuntu 8.10 Intrepid ===
 +
 
 +
Simply uncomment the line '''s/keycode  58 = Caps_Lock/keycode  58 = Control/;''' in this file:
 +
 
 +
<pre>
 +
/etc/kbd/remap
 +
</pre>
 +
 
 +
=== Ubuntu before 8.10 Intrepid ===
 +
 
 +
The keyboard maps in Ubuntu are stored here:
  
 
<pre>
 
<pre>
 
/usr/share/keymaps/i386/qwerty/defkeymap.kmap.gz
 
/usr/share/keymaps/i386/qwerty/defkeymap.kmap.gz
 
</pre>
 
</pre>
 +
 +
=== Red Hat Enterprise 4 ===
  
 
On Red Hat Enterprise 4 the file is stored here:
 
On Red Hat Enterprise 4 the file is stored here:
Line 23: Line 48:
 
/lib/kbd/keymaps/i386/qwerty/defkeymap.map.gz
 
/lib/kbd/keymaps/i386/qwerty/defkeymap.map.gz
 
</pre>
 
</pre>
 +
 +
 +
=== old script to fix defkeymap on Ubuntu ===
  
 
The following script takes care of this for Ubuntu Linux:
 
The following script takes care of this for Ubuntu Linux:

Revision as of 17:33, 18 February 2009


CapsLock is Satan

On most PC keyboards the Caps Lock key is where the Ctrl key should be. Whenever I get a new keyboard or laptop, I always pop off the key then take a razor blade and scrape off the "Caps Lock" print. I then tweak my operating system so that it thinks this key is a Ctrl key. Some people like to make it another Esc key.

Windows

Go here Sysinternals ctrl2cap.

Linux Console

You just need to remap keycode 58 from "Caps_Lock" to "Control" then load using loadkeys. Many Linux distros actually have hooks in place to do this for you. This is the command that will do the trick (run this as root):

dumpkeys | sed 's/58 = Caps_Lock/58 = Control/' | loadkeys

I put this in my global alias file:

alias killcaps='sudo dumpkeys | sed \'s/58 = Caps_Lock/58 = Control/\' | loadkeys'

Most distros put these types of commands into a keymap file. The keymap files are stored in different places depending on your version of Linux. It is sometimes called "defkeymap" or "remap".

Newer Ubuntu 8.10 Intrepid

Simply uncomment the line s/keycode 58 = Caps_Lock/keycode 58 = Control/; in this file:

/etc/kbd/remap

Ubuntu before 8.10 Intrepid

The keyboard maps in Ubuntu are stored here:

/usr/share/keymaps/i386/qwerty/defkeymap.kmap.gz

Red Hat Enterprise 4

On Red Hat Enterprise 4 the file is stored here:

/lib/kbd/keymaps/i386/qwerty/defkeymap.map.gz


old script to fix defkeymap on Ubuntu

The following script takes care of this for Ubuntu Linux:

#!/bin/sh
echo "transmogrify the Caps_Lock key into another Control key"
gunzip /usr/share/keymaps/i386/qwerty/defkeymap.kmap.gz
sed -i -e "s/Caps_Lock/Control/" /usr/share/keymaps/i386/qwerty/defkeymap.kmap
gzip /usr/share/keymaps/i386/qwerty/defkeymap.kmap
loadkeys -d

console-tools

This can also be done through console-tools. Edit '/etc/console-tools/remap' and uncomment 'keycode 58'.

X11

When running XWindows you need to modify the X11 key map using xmodmap. It is not sufficient to just modify the console keyboard mapping. Use xmodmap to load the following keymap file (save in ~/.Xmodmap):

remove Lock = Caps_Lock
keycode 0x42 = Control_L
add Control = Control_L

make these changes persistent

These keyboard settings are not persistent after a reboot. Most Linuxes will load your ~/.Xmodmap file when you login with xdm or gdm. Some don't. If not then you should add this line to your ~/.xsession and ~/.xinitrc files (after the shebang #!/bin/sh line):

[ -f ~/.Xmodmap ] && xmodmap ~/.Xmodmap

X11 Gnome/Ubuntu

Go to you main panel menu and select the following to get to the CapsLock as Ctrl option:

System
  Preferences
    Keyboard  --> opens "Keyboard Preferences" dialod
      Layouts tab
        Layout Options...
          Ctrl key position
            Make CapsLock an additional Ctrl.