When reading either of these questions or the EmacsWiki article about mapping Caps Lock to Control in emacs in Windows, the best answers seem to involve the registry. My que
The simplest way to remap CapsLock on Windows is to download this CapsLockChanger utility, choose a key to map to (Control) and put it in your Start->Startup menu.
It stays in your tray, does the job on key remapping and does not require messing around with registry.
I believe it doesn't work because Windows (or X) doesn't pass an actual event for [capslock]
or [control]
- it's a modifier key, like [shift]
. Pressing a modifier key doesn't cause the application to get a keystroke, but if you press a modifier and a second (non-modifier) key, then you get the keystroke.
For example [a]
and [A]
are two different keys, one is the regular "a" and the other is essentially "shift-a". I'm sure you could set Windows up to have the "shift-a" actually send a "z" or something.
Because [capslock]
, [control]
, [shift]
, [meta]
are all modifier keys, they don't generate key events in and of themselves for the applications.
In short, Emacs doesn't get a [control]
key event that it can remap, it gets a C-a
event. This is generally done by the obvious combination of [control]
and [a]
keys. But, the event could be generated by a different keystroke, say [F10]
or even [y]
(confusing, yes).
This is how I understand it. Clarifications are welcome of course.
You do not necessarily need Admin rights in order to modify the registry.
In fact, the Windows Registry is a segmented resource, much like a filesystem, and you can have granular permissions on various branches and nodes within the registry.
Are you sure your assumption that you cannot change the registry, is correct?
I think it is true by default on Vista, but not on previous Windows.
I know this does not really answer your question, but Trey Jackson basically explained the problem. To detect control key alone requires low-level keyboard hook on Windows, which I don't think Emacs implements.
One way (involving external program, but does not require admin right) is to use AutoHotkey. All you need is the following 2 line script:
CapsLock::Ctrl
LCtrl::Capslock
You will need to run this script whenever emacs is open, but thankfully Autohotkey is pretty low profile application (usually takes about a few hundreds Kb in memory only). You can for example execute this script in your .emacs so that your control key and capslock key are swapped whenever emacs is opened.