Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

2 Answers 2

up vote 7 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.