32

How can I remap the Caps Lock key in Windows or OS X? Is there, for example, some way to map caps lock to a key combination like Alt+Tab on Windows or +Tab on OS X?

CAPS LOCK

splattne
  • 16,056

10 Answers10

17

You need Autohotkey and this script:

;Deactive CapsLock key 
$CapsLock:: 
return

Autohotkey is THE most powerful way to do this sort of thing on a WIndows PC. Also see this page for more details on re-mapping CAPS,

Ash
  • 2,851
11

I've used SharpKeys (for windows) to remap CapsLock to ESC.

Works great for vim. VI-style editing really shines if you can keep your fingers near the home row at all times.

wcoenen
  • 2,340
9

Here's how to swap the Caps Lock key with left Ctrl:

Windows

  1. Click Start > Run
  2. Type "regedit"
  3. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
  4. While Keyboard Layout has focus, go to Edit > New > Binary Value
  5. Enter "Scancode Map" as the name
  6. Enter the following as the Data:

    0000: 00 00 00 00 00 00 00 00
    0008: 03 00 00 00 3A 00 1D 00
    0010: 1D 00 3A 00 00 00 00 00
    
  7. Exit the Registry Editor

  8. Log out and log back into Windows

Linux

  1. Create a file in your home directory called .xmodmap if it doesn't already exist
  2. Paste the following lines into the file:

    remove Lock = Caps_Lock
    remove Control = Control_L
    keysym Control_L = Caps_Lock
    keysym Caps_Lock = Control_L
    add Lock = Caps_Lock
    add Control = Control_L
    
  3. Add the following line into ~/.bash_profile

    xmodmap ~/.xmodmap
    

Source

Jasper
  • 213
7

You can use SharpKeys to disable the functionality of any key. For a detailed guide, you can check out Map Any Key to Any Key on Windows XP / Vista.

Aditionally, Lifehacker has a really good guide called NumLocker Disables the Caps Lock Key on how to remap or disable it entirely.

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
Josh Hunt
  • 21,369
7

on Mac: You can reassign the caps lock key under "System Prefs" -> "Keyboard & Mouse" -> "Special Keys".

i assigned it to CTRL

quentin
  • 276
3

I use Billy Mays Caps Lock. Now whenever I accidentally hit the Caps Lock key instead of getting frustrated I hear a quick Billy Mays pitch, which always puts a smile on my face.

2

SysInternals' Ctrl2Cap will work on older Win machines, too.

Doug Harris
  • 28,397
2

On Mac I can recommend using KeyRemap4MacBook. Or PcKeyboardHack which has a slightly different focus. I use both in combination without any problems.

The problem is, there is no out of the box solution built in to Mac OSX so you could assign CAPS LOCK to ESC (which is essential for Vi/Vim). The second problem with other tools is that they don't disable the green LED on the Caps-Lock Key.

PcKeyboardHack is related to the ESC-mapping, but every mapping is possible. KeyRemap4MacBook directly allows to map to a different function key. For sure every mapping you like is possible So for example on Mac I have mapped the right -Key to ctrl (what comes in handy when you are accustomed to eclipse-like autocompletion on Windows)

1

Swapping it with a different modifier key (I like Ctrl) is supported by Mac OS:

keyboard control panel -> modifier keys
Jasper
  • 213
1

As Marchal said, on OS X you can use PCKeyboardHack to change caps lock to another key like F19:

You can map the key like F19 to a more complex key combination by adding a setting like this to private.xml in KeyRemap4MacBook:

<autogen>__KeyToKey__ KeyCode::F19, KeyCode::CONTROL_L, ModifierFlag::CONTROL_L |
ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::COMMAND_L</autogen>

If the caps lock light on your keyboard does not get disabled, try enabling the "Pass-Through caps lock LED status" setting in KeyRemap4MacBook.

This maps F19 to control when held and to escape when pressed:

<autogen>__KeyOverlaidModifier__ KeyCode::F19, KeyCode::CONTROL_L, KeyCode::ESCAPE</autogen>

You can also map F19 to an extra modifier key that can be used to for example activate applications:

<vkopenurldef>
  <name>KeyCode::VK_OPEN_URL_SAFARI</name>
  <url>file:///Applications/Safari.app</url>
</vkopenurldef>
<item>
  <name>test</name>
  <identifier>test</identifier>
  <autogen>__KeyToKey__ KeyCode::F19, KeyCode::VK_MODIFIER_EXTRA1</autogen>
  <autogen>__KeyToKey__ KeyCode::S, ModifierFlag::EXTRA1,
  KeyCode::VK_OPEN_URL_SAFARI</autogen>
</item>

See http://lri.me/keyremap4macbook.html for more information about using KeyRemap4MacBook.

Lri
  • 42,502
  • 8
  • 126
  • 159