Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I remap the Capslock key to ESC in a Windows Cygwin shell?

Ideally I would only remap the value in Cygwin shells instead of everywhere, preserving behavior in other apps (although admittedly even in Windows I think I probably hit the Capslock key more frequently by accident than on purpose).

Even better would be something I could add to my bashrc, making it easily portable.

Background: I spend most of my time in Linux where I've used xmodmap (like this, http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_XWindows) to remap Capslock to Esc for speed and comfort with vi. This works great everywhere on those systems, i.e. in vim and also on a bash commandline. For the remaining time when I'm in Cygwin on a windows box, my muscle memory has me hitting the capslock key to ill effect!

share|improve this question

migrated from stackoverflow.com Nov 27 '12 at 23:45

This question came from our site for professional and enthusiast programmers.

up vote 8 down vote accepted

I do the remapping system-wide via the registry modification outlined at http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows.

On the same page, there's also an AutoHotkey solution.

You can limit the scope of AutoHotkey remappings like this, which should (untested!) limit to Windows console windows:

#IfWinActive ahk_class ConsoleWindowClass
CapsLock::
...

If you use the new Mintty-based Cygwin Terminal, that would then apply exclusively to Cygwin. (But I'd still recommend you try the system-wide remapping first; I've put Caps Lock on Scroll Lock as a fallback, but I rarely if ever use it.)

share|improve this answer
    
+1 for AutoHotKey. Although it is ludicrous that remapping keys is so difficult in Windows. – Prince Goulash Nov 28 '12 at 13:10

I do not know how to remap Capslock only in Cygwin. But in Windows 7 globally remap

CapsLock to Esc just add a register key:

[HKEY_CURRENT_USER\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00

CapsLock to Ctrl:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00

Use Current_User or Local_Machine whatever meets your needs better.

Other mappings

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .