Reassigning the caps lock key on Windows or OS X

30

13

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

Posted 2009-07-15T12:27:16.837

Reputation: 14 208

21YES, PLEASE TELL ME - HOW CAN I DISABLE THIS DARNED THING!? ;-) – Chris W. Rea – 2009-07-16T02:32:41.437

2

CapsLock might be the most useless key nowadays. '[Lenovo Vice-President David] Hill called “Caps Lock” a frustrating hangover from typewriter days, a key that can introduce garble, emulate shouting or foil password entries without the user noticing.', http://www.insidetech.com/news/articles/5143-lenovo-tries-to-improve-keyboard-layout-in-latest-notebook

– VolkerK – 2009-07-20T09:42:42.900

1Unbelievable that four years have gone by, and Windows STILL does not have a built-in way to permanently disable Caps Lock and Num Lock. – William Jockusch – 2013-12-16T01:00:36.140

Answers

16

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

Posted 2009-07-15T12:27:16.837

Reputation: 2 611

Very nice, thank you! As soon as I have time I'll look into it. – splattne – 2009-07-15T14:40:38.047

I've remapped Caps to LCtrl. It was a lot more natural for my hand go to the left that turn -60degres and extend the little finger to grab the LCtrl key. After months of this change the pain that i was felling to doing that repetitive movement was gone completely – mjsr – 2011-08-14T16:57:47.520

3Was coming to suggest the same thing. I've remapped CapsLock to Escape to aid in Vim editing :D – Andy – 2009-07-18T11:37:06.383

This does not work with my japoanese keyboard. Instead, the CapsLock key gets replaced by the 半角/全角 key.

– wip – 2013-06-28T02:38:49.947

@wil: on Japanese keyboard, pressing shift+Capslock will do normal Capslock function – phuclv – 2013-10-07T05:23:19.257

10

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

Posted 2009-07-15T12:27:16.837

Reputation: 2 060

Even better is mapping CapsLock to Ctrl. Ctrl+[ is the same as escape and now you have an easier to reach Ctrl for other key combinations. – Michael Brown – 2014-10-15T19:25:17.730

This is the best tool I have come across in over 6 years of disabling the caps-lock key, mapping my IBM Model M's right ALT key to the Windows key, etc. It simply records to the registry the necessary changes, but has a nice interface to facilitate that effort. And it isn't installed as an app, it is a simple utility. – Jason Bunting – 2010-06-19T04:26:47.070

Too bad Windows-7 is not supported. – WilliamKF – 2011-04-15T04:21:15.970

@WilliamKF: I am using SharpKeys on Windows 7. It works fine. – wcoenen – 2011-04-15T08:14:10.093

@WilliamKF: I'm also using SharpKeys on Win7. Chek that you execute it with administrative permissions. – mjsr – 2011-08-14T17:00:07.983

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

Andrew Hampton

Posted 2009-07-15T12:27:16.837

Reputation: 693

hey, could you please answer me the esc key code? I want to swap Caps with Esc key. – MaikoID – 2017-07-20T17:15:05.923

It should be noted that most graphical environments on Linux offer a way to set the caps lock key behavior in whatever keyboard configuration tool it offers. It can also be modified in the standard keymap for the console. – greyfade – 2011-12-27T23:45:17.573

Excellent. This was what I was looking for and I didn't find the solution with MSKLC. Thanks a bunch (and +1 of course). – 0xC0000022L – 2012-12-24T13:10:46.343

8

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

i assigned it to CTRL

quentin

Posted 2009-07-15T12:27:16.837

Reputation: 286

3This is so damn simple, why do we need an app for this on Windows? – rightfold – 2011-07-06T14:01:29.060

@WTP Better yet, for proper remapping (rather than AutoHotkey-esque macros) you need admin rights as well as of Windows 7. Begging IT in a corporate environment for that doesn't seem to be going over well for me. – brymck – 2012-07-12T05:09:56.073

1On Snow Leopard, it's "System Prefs" -> "Keyboard" -> "Modifier Keys". – Marcel Levy – 2009-11-01T21:22:31.180

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.

Josh Hunt

Posted 2009-07-15T12:27:16.837

Reputation: 20 095

@splattne for map a combination use Autohotkey. It is extremely simple to do it, for example: CapsLock:: SendInput !{Tab}, it will send Alt Tab when you press the Caps – mjsr – 2011-08-14T17:02:47.357

Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.

– Der Hochstapler – 2012-12-18T17:14:47.210

Thanks for the SharpKeys link! Sadly, there seems no way to map a key to a combination of keys in the program (I read the FAQ). – splattne – 2009-07-15T13:07:28.980

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.

スーパーファミコン

Posted 2009-07-15T12:27:16.837

Reputation: 4 719

2

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

Doug Harris

Posted 2009-07-15T12:27:16.837

Reputation: 23 578

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)

Marschal

Posted 2009-07-15T12:27:16.837

Reputation: 21

1

FYI: KeyRemap4MacBook has been rebranded to Karabiner and even supports Yosemite (OS X 10.10)! https://pqrs.org/osx/karabiner/index.html.en

– SaxDaddy – 2014-07-29T00:56:34.540

1I just started using KeyRemap4MacBook this morning, and I love it. I have caps lock set to both esc and ctrl. It's esc when it's the only key being pressed, and it switches to ctrl if I press any other keys. – Dean – 2013-10-18T05:51:33.153

@Dean glad to hear about it! – Marschal – 2013-10-18T07:37:31.287

1

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

keyboard control panel -> modifier keys

Fabian Steeg

Posted 2009-07-15T12:27:16.837

Reputation: 166

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

Posted 2009-07-15T12:27:16.837

Reputation: 34 501