Difference between revisions of "CapsLock Remap Howto"

From Noah.org
Jump to navigationJump to search
m
m
Line 1: Line 1:
 
+
== CapsLock remap How To ==
 
On most PC keyboards the Caps Lock key is where the Ctrl key should be.
 
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
 
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.
 
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.
  
Basically you need to remap keycode 58 from "Caps_Lock" to "Control"
+
== remap the console keyboard ==
 +
You just need to remap keycode 58 from "Caps_Lock" to "Control"
 
in your keymap file, then load the keymap using loadkeys.
 
in your keymap file, then load the keymap using loadkeys.
Some people like to make it another Esc key.
 
  
 
The keymap files are stored in different places depending on your
 
The keymap files are stored in different places depending on your
Line 25: Line 27:
 
</pre>
 
</pre>
  
 +
== remap the X11 keyboard ==
 
When running XWindows you need to modify the X11 key map using xmodmap.
 
When running XWindows you need to modify the X11 key map using xmodmap.
 
It is not sufficient to just modify the console keyboard mapping.
 
It is not sufficient to just modify the console keyboard mapping.
Line 35: Line 38:
  
 
These keyboard settings are not persistent after a reboot.
 
These keyboard settings are not persistent after a reboot.
You can edit the ... FIXME ...
+
You can edit the the init.d setting if available or you
 
+
can run these scripts every time you login.
 
I add this to my .bashrc file. This is a bit overkill since it
 
I add this to my .bashrc file. This is a bit overkill since it
 
will run this everytime I start a shell, but loadkeys and xmodmap
 
will run this everytime I start a shell, but loadkeys and xmodmap
 
takes no time at all, but it's harmless.
 
takes no time at all, but it's harmless.
 
 
<pre>case "$TERM" in
 
<pre>case "$TERM" in
 
xterm*|rxvt*)
 
xterm*|rxvt*)

Revision as of 09:09, 6 August 2006

CapsLock remap How To

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.

remap the console keyboard

You just need to remap keycode 58 from "Caps_Lock" to "Control" in your keymap file, then load the keymap using loadkeys.

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:

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

On Red Hat Enterprise 4 this file is stored here:

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

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

remap the X11 keyboard

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:

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

These keyboard settings are not persistent after a reboot. You can edit the the init.d setting if available or you can run these scripts every time you login. I add this to my .bashrc file. This is a bit overkill since it will run this everytime I start a shell, but loadkeys and xmodmap takes no time at all, but it's harmless.

case "$TERM" in
xterm*|rxvt*)
    # X terminals
    if [ -f ~/.xmodmap ]; then
        xmodmap -quiet ~/.xmodmap 2>/dev/null
    fi
    ;;
*)
    # console
    LK=`which loadkeys 2>/dev/null`
    if [ -x "$$LK" ]; then
        loadkeys -d
    fi
    ;;
esac