tags:

views:

930

answers:

4

I am looking for a way to have my control key and caps-lock key switched when I am in the emacs window, but when I go to any other program such as Firefox I want to be able to use the normal control button for new windows, tabs and such.

Additional Information: I am using Ubuntu, but answers for all systems are good since someone else may want to know how to do it on their system.

+1  A: 

For globally remapping keys there is xmodmap. xkeycaps is an interactive tool. You can put control on both keys.

Since you want to remap the keys only for Emacs (which I find somewhat ill-advised) you need to look inside Emacs for a solution. It should be possible, because you can rebind all keys, but it may be too tedious to swap all keys around if the modifiers cannot be swapped.

Personally I map CapsLock to Compose, to type all kinds of funny characters like ä, ß, å, þ, «, —, ...

starblue
The reason why I want it is because when I globally remap the keys and someone else uses the computer I am given non-stop shit for it.
Anton
+2  A: 

On windows using Auto Hot Key you can achieve this with this piece of code put in default script:

#IfWinActive, emacs@      
    CapsLock::Control
#IfWinActive

Auto Hot Key is a very handy utility and it is also free software like in GPL.

boskom
+7  A: 

Emacs never actually sees the CapsLock keycode (under X anyway), so you can't remap the key in Lisp. Take a look at this page for details:

http://www.emacswiki.org/emacs/MovingTheCtrlKey

jrockway
+1  A: 

Maybe this helps. There is also a solution for windows without messing up with register.

Serge