51 comments

[ 5.0 ms ] story [ 101 ms ] thread
I solved this problem many years ago by switching to a keyboard with a better layout.

I'd thoroughly recommend a HHKB to any programmer.

Never switching back to something that isn’t Ergo 4000 or Ergo 4000 shaped if they ever stop making them.

Nothing is as comfortable for me and I’ve tried a few, so remapping caps is still useful to me.

Nice, how is linus support (regarding extra scrollwheel, buttons..)
Works fine, media keys all work out the box fedora/cinnamon and you can remap the extra keys however you want, I have the star mapped to Trello and 1 through 5 mapped to particular Trello boards etc.

Been using them with Linux for about 5 years with no issues at all, yet to have one fail, the one I use at work the letters all wore off and I eventually wore through the faux leather padding surface but it's a nice high density foam so it's not breaking up.

I've taken them apart a few times down to boards out and keycaps off to clean them with no issues.

For a properly ergonomic keyboard at that price they are damn hard to beat so much so I have a spare new in box and am thinking of buying another just in case.

I fully respect your choice :)

As a hopefully interesting comparison, for me the right choice is a logical layout that is decoupled from the physical layout. And a Russian physical layout keyboard from Apple. And an US software layout.

(I'm Icelandic and don't speak or write Russian. Not yet at least.)

The Russian keyboard has all the programming symbols in the right places, a two-story enter key, and has the key between left-shift and Z. And gorgeous Cyrillic symbols on each key, in addition to the English-layout keys. Then my fingers sit on something beautiful that they know.

Russian layout: https://store.storeimages.cdn-apple.com/4982/as-images.apple...

US layout: https://store.storeimages.cdn-apple.com/4982/as-images.apple...

And I love the crisp action that Apple's keyboards have today. – I appreciate that some don't like the feel. That's why we need a rainbow of variety!

Then I remap things in software. I personally remap Caps Lock to Ctrl and keep Esc where it is.

>two-story enter, key between lshift/z

It is not very Russian though. We call it European on your first pic. And Russian ~= Asian, as shown here http://xahlee.info/kbd/russian_keyboard_layout.html

Last decade layouts shuffled here heavily, probably due to supplier chain ignorance, and also laptop-like keyboard vendors, who put keys randomly to save space. It is a headache to find a good keyboard with the layout you used to.

That's interesting. When you order from the Apple website from German region, you can choose e.g. English (US) and English (International). But US region does not allow to choose English (International).

- English (International) layout: https://store.storeimages.cdn-apple.com/4668/as-images.apple...

- English (US) layout: https://store.storeimages.cdn-apple.com/4668/as-images.apple...

- Russian layout: https://store.storeimages.cdn-apple.com/4982/as-images.apple...

English International is a good option on a Mac.

For Windows/Linux, an easily available European keyboard with the double-height enter, extra key next to Z, and most of the "programming" keys in the same place as the American layout is the British/Irish layout.

(The main difference is " and @ are swapped. Shift-3 becomes £, but that pushes # to the extra, unshifted key, which is a plus. I have never used ¬.)

It would be nice to find a store where you can actually try the keyboards before to buy. I am using a Microsoft keyboard since 10 years and unable to accomodate with anything else, already wasted money for around 10 more keyboards with no luck. They are good as gift only, but everybody is bored already on my keyboard gift surprises :)
The tool itself is actually Windows-only, it seems.

Also, a more interesting question would be how to map caps lock to ctrl (or something else) on hold, and esc on tap, across platforms.

Ditto return key: return on tap, ctrl on hold.
Indeed, the tool itself is windows but repository contains a list of alternatives: https://github.com/susam/uncap#alternatives

`$ setxkbmap -option caps:escape` is exactly what I use. Very helpful of the author of the tool to include simpler/alternatives to the tool. Kudos!

After doing this (ctrl on hold and escape on tap) on every system I use, I wrote a blog post with instructions: https://www.dannyguo.com/blog/remap-caps-lock-to-escape-and-...
Oh, that's nice! I had capslock mapped to control, but I wanted to have escape on tap as well. But I never bothered to figure it out on Wayland.

Turns out you can enable caps2esc, which is mentioned in the blog post, on NixOS with a single line:

    services.interception-tools.enable = true;
> a more interesting question would be how to map caps lock to ctrl (or something else) on hold, and esc on tap, across platforms.

Definitely agree. I'm a big fan of that behavior. It would be nice to have a single project that supports it cross-platform. At the moment, I'm doing:

On linux, https://github.com/alols/xcape .

On OSX, https://github.com/tekezo/Karabiner-Elements after some setup.

Not sure about windows. Maybe there's some AHK script out there for it?

I used this configuration when I was in grad school and developed RSI in my left pinky. I highly recommend caps to esc and alt to ctrl so that thumbs can hold down keys while other digits just tap keys. Less stress on pinky.
Why does one need this on macOS (which has had a dedicated toggle for this in System Preferences for a few versions now)?
For the casual reader who does not know:

* Start app 'System Preferences'

* Pick 'Keyboard'

* Click button 'Modifier Keys...'

* Per keyboard you can now configure what the caps lock key does. One of the options is 'escape'. Which is what it should be :)

Easter egg in the source code: https://github.com/susam/uncap/blob/78f52d7b2e03fc51885c8072...

Output:

  ...............................................................
  ...............................................................
  .................. @@@@@@@ ......... @@@@@@@ ..................
  ............... @@@@     @@@@ ... @@@@     @@@@ ...............
  ............. @@@           @@@ @@@           @@@ .............
  ............ @@@               @               @@@ ............
  ............ @@@    Cutie Pai,                 @@@ ............
  ............ @@@                               @@@ ............
  ............. @@@         I love you!         @@@ .............
  ............... @@@@                       @@@@ ...............
  .................. @@@@     -- Susam    @@@@ ..................
  ..................... @@@@           @@@@ .....................
  ........................ @@@@     @@@@ ........................
  ........................... @@@ @@@ ...........................
  .............................. @ ..............................
  ...............................................................
  ...............................................................
On Linux I use GNOME Tweaks to rebind it to escape (though you can also use xmodmap directly). It doesn't work on console, and I don't think it works in Wayland either (!!).

on Mac I use Karabiner Elements to rebind it to escape (though you can also use System Preferences).

On Windows -which I try to avoid- I use a registry edit to disable caps lock which one can find via a search engine (do verify the contents). This has the advantage that you can still bind it e.g. in games (such as for push-to-talk).

For those who search a AutoHotKey (AHK) alternative on Linux, consider AutoKey [1] which has Python scripting support.

[1] https://github.com/autokey/autokey/

I just use AutoHotKey because I'm already using AHK for so many things.

On Windows, I think most people who would want to remap these keys are already using AutoHotKey to set up custom global hotkeys or do other tweaks.

The entire AHK script is a 2 liner that you can put into an existing script, such as:

    CapsLock::Esc
    Esc::CapsLock
Only including that here because the OP's alternative AHK example in the readme remaps CapsLock to Escape, but it doesn't include remapping Esc to CapsLock (both are necessary to swap the keys).

His current example would leave your Esc key unchanged, meaning you would have 2 escape keys and 0 CapsLock keys.

I suspect it was intentional as I too would want 0 keys mapped to CapsLock.

Is there a way with AHK to map CapsLock tapped by itself to Esc and held with other keys as Ctrl?

I've never tried that behavior and I'm also not an AHK wizard (I use it for a few global hotkeys, remapping escape and some small tweaks).

But Google came up with this: https://autohotkey.com/board/topic/104173-capslock-to-contro...

The last reply's code sample looks like it would do what you want in a non-buggy way. If not, there were about 20 other Google results for combo mapping CapsLock to CTRL and / or Escape depending on how it was pressed.

On Linux you can either set it in gnome or, if you are using a wm, just run setxkmbap -option caps:escape.
Can someone explain what's the purpose of this remapping?

Is this for MacBook Pro models with a Touch Bar, or is it something else altogether? In the former case, a better title would be "Map Escape to Caps Lock".

I use vim, so esc is one of the most important keys. But I use esc in most apps very frequently. I don’t use Caps Lock at all.
I still don't get it. We have a keyboard with an Esc key and a Caps Lock key. Why would I remove Caps Lock and use it as another Esc key?
Try pressing esc every few seconds for 8-12hrs a day like a vim developer does and you'll know.
(Single datapoint ahead.)

I edit my sources and remote configs exclusively in vim-likes since ~2004 (full time sw dev) and never experienced such issues. From my experience, typing or clicking speed requirement rarely exceeds that of thinking on your program. I hit esc often, but not too often, and it is not too far.

I’m not against caps->esc mapping in general, but for me this would have little to no value plus non-standard layout, which is minus, since I’m not office-only guy.

Inverse: question you have a big key, in the home row. That is a very valuable keyboard position.

What is a function in your programs deserve such a prominent position??

In my case as an emacs user bloq mayus, get's remaped to CTRL.

Vin users need ESC.

I don't understand it either. I have mapped caps lock to some command launcher/window switcher, which spares me pressing two keys.. Esc is even on the same side as the keyboard..

Rofi: https://github.com/davatorium/rofi

> I don't understand it either [...] Esc is even on the same side as the keyboard

Put your hands on the keyboard home row (where they belong).

Try to reach esc without taking them out of there. Hurts, don't it?

Now try reaching caps lock. Much better, right?

That's why.

Caps lock is useless. Esc is extremely useful (for vi users). So we get rid of caps lock and put something more useful there.

I don’t use vim as often (~20%), so I’ve mapped caps lock to Esc, and Esc to AltGr — which doesn’t exist in EN-Int layout. The benefit is that I can assign AltGr+{1,2,3,4...} as quick contextual hotkeys without overriding any default combos.
I only use keyboards with QMK firmware these days. It's much easier to flash a new layout to my keyboard than it is to keep messing around with OS settings for keyboards.
+1. I too use a custom keyboard with QMK firmware. In addition to mapping Caps Lock to Esc, I also map holding down of Caps Lock to Ctrl.
I bind it to Scroll Lock, which I absolutely never use. That way I have a conveniently reachable key to use for whatever I need atm.
Is this just for VIM users or is there another reason why someone would want to specifically remap the Escape key and ditch the Caps Lock?
I as emacs user prefer ESC-x to ALT-x with ESC at CAPS because it is simpler to me.
But why not real ALT-x to CAPS-x instead?
On Windows I just use remapkey.exe.

Let’s you remap anything with a nice GUI editor to boot.

My non-official download here: https://stuff.kjonigsen.net/remapkey.exe

As for random EXEs on the Internet, you’ll have to trust me or find alternate sources.

It’s a good tool. Does one thing and does it well.

PSA: In VIM ctrl-c does the same as ESC. No need to remap of you relearn.
This is not entirely true, and the differences between them sometimes matter. If you want an equivalent, go for CTRL-[, which is actually equivalent.

If you’re interested in some of the differences, start in `:help ins-special-keys`.

EDIT: This is actually already mentioned in the README

This seems like the wrong approach to remap keys on Windows. This tool is using a keyboard hook, so it needs to run always for the remapping to work.

Windows already has a way of remapping keys through the registry that will persist over reboots, without re-running the tool. There are many GUI tools for modifying the key-mapping in registry, I use SharpKeys (https://archive.codeplex.com/?p=sharpkeys)

For anyone looking for a new keyboard with custom key maps, I’d really recommend the Kinesis advantage. I switched to it 8 years ago to fend off carpal tunnel after my old keyboard was bothering my wrists. It was easy to get used to and now whenever I’m on my Macbook’s keyboard, it feels archaic. It’s strange that by default (probably a relic from typewriters) we use our most important digits solely for bashing on the space bar.

It also has built-in key remapping so you don’t need to mess with anything on the OS level.

I use win compose on Windows and whatever built in tools on KDE in Linux to treat caps lock as the compose key.

This allows me to type special characters in an intuitive way, such as producing © with compose o c, or π with compose p i, along with definable custom shortcuts.