7

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.

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
Anton
  • 12,285
  • 20
  • 64
  • 84
  • 1
    It takes just one command (`xmodmap ~/.xmodmap-swap`, for example -- you can even make a shortcut to it in your taskbar) to swap the keys back to normal before giving it to someone else to use :) – ShreevatsaR Feb 04 '09 at 00:24

3 Answers3

8

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
  • 42,082
  • 9
  • 61
  • 86
7

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
  • 840
  • 1
  • 7
  • 12
2

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
  • 55,348
  • 14
  • 97
  • 151
  • 1
    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 Feb 03 '09 at 23:37