Turning on Caps Lock when the Caps Lock key is bound to a different key

As a Vim user, and as someone who doesn't use CapsLock very often, I've had my CapsLock key rebound to ESC for the last 7(!) years.

In the last week I've had a couple of times where my new work laptop's lost the configuration, and I've accidentally hit CapsLock which has then actually set Caps Lock instead of triggering ESC. I've generally then reset my keybindings before noticing that I've got Caps Lock turned, on, which has led to me being unable to turn it off, or even type in my terminal to unset it.

This has been a little bit embarrassing, so when it's just happened to me right now, I was very happy to find, via this AskUbuntu answer, that we can use xdotool to trigger the event:

# Note the capitals
xdotool key Caps_Lock

This is great because it surprisingly doesn't get picked up by any rebinding, and will correctly (un)set Caps Lock.

Another clever commenter suggested something I'd rarely have considered - use the Shift key while in Caps Lock to return to normal casing.

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #linux #command-line.

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.