Skip to main content


I never use Caps Lock, so I disable the Caps Lock key completely with xmodmap, to avoid hitting it by accident.

Occasionally my X server gets into caps-lock state anyway. (Usually some complicated stunt was involved, like attaching x11vnc to the display remotely.) And then I can't turn it off again using the Caps Lock key.

So I wrote a tiny X client that lets me type 'xcapslock off' at a shell prompt …

… and then I had to make an alias to it, called 'XCAPSLOCK OFF'.

reshared this

in reply to Simon Tatham

I modified my keymap so that I have to press shift+capslock (or shift+numlock) to lock/unlock them. So, no accidental triggering anymore, but I can still use it if I really want to
in reply to PulkoMandy

@pulkomandy neat – I don't know how to do that, on any OS. On X11 (which I know best) I'm 75% sure there's no way to do it with plain xmodmap, but maybe the richer XInput API has a way?
in reply to Simon Tatham

I have this for numlock but I'm not entirely sure of what it does:

xmodmap -e 'keycode 77 = NoSymbol Num_Lock'

I didn't try caps lock yet, does it not have a keycode, or would it just be confused about shift?

in reply to PulkoMandy

@pulkomandy aha, nice! Generally 'keycode K = a b c d' means that K generates symbol a unshifted, b shifted, and I think c with AltGr and d with both modifiers.

xmodmap -e 'keycode 66 = NoSymbol Caps_Lock' is the Caps Lock equivalent of your Num Lock line. So I was wrong (or perhaps '25% wrong' 😀. You _can_ do it with plain xmodmap.

in reply to Simon Tatham

@pulkomandy the Japanese keymap has that by default (without Shift it's part of Japanese IME, with Shift it's CapsLock), so that would be a good starting point to see how it's done in different systems.
Unknown parent

mastodon - Link to source
Simon Tatham
@failedLyndonLaRouchite I've seen at least one person go in the opposite direction and just take the keycap off. The little cross-shaped nubbin sticking up in the centre of the hole is much smaller, so a harder target for an accidental finger-flail.
in reply to Simon Tatham

I simply remove the capslock key from every keyboard I ever have to use more than once.
in reply to Simon Tatham

I have mapped it to a weird key combination for that reason, that I have to look up everytime this happens.
in reply to Simon Tatham

Caps Lock becomes Escape for me on any machine I spend any time on.
in reply to Alexander Dyas

@alexanderdyas since my previous view of Caps Lock was 'that key I used to keep hitting by accident', I never quite felt it would be a good idea to remap it to any actual action, even a more useful one 😀
in reply to Simon Tatham

I've taken to solving this one layer below: you can mess with the event system to remap keys even before X ever sees them. Additional benefit is that they're remapped even on the console.
The downside is that you might have to do this for every keyboard you have on the system, as they don't necessarily agree on the low level key codes. Specifically the built-in laptop keyboard usually doesn't use USB key codes.
in reply to Lalufu

I must admit that I also cling to an old-fashioned idea that computers are still multi-user. Even my personal ones: I have been known to give other people accounts on them, and when those people use their accounts, they _don't_ want the effects of bizarre things like this intended for just me.

So I still think it makes more sense to put my preferences in my account, not systemwide. This is also a reason I haven't taken the Caps Lock keycap off.

This entry was edited (5 months ago)
in reply to Lalufu

@Lalufu though admittedly one flaw in this concept is the login screen. If I have a preferred keyboard layout that's not the systemwide one, I'd like to use it to type my password – especially since I'll _also_ sometimes need to type my password after logging in, and it's doubly annoying to do it in two different finger shapes!

I don't know if any login-screen software temporarily enables each user's keyboard preferences for their password prompt. Or even if it _could_, securely.

in reply to Simon Tatham

@Simon Tatham @Lalufu I think I’ve seen it done, with a display manager (can’t remember which) maintaining a cache of preferred session type and keyboard layout for each username.
in reply to Simon Tatham

I may have some aliases along those lines.

alias nordconnect="nordvpn connect"

in reply to Simon Tatham

Maybe you need a "Caps Lock Lock" key. Usually you'll leave Caps Lock disabled, but when you need it, the "Caps Lock Unlock" feature is right there! ;)
in reply to Simon Tatham

I use a HHKB that has the Ctrl key where Caps Lock usually is. When I need Caps Lock, I set left shift + right shift combo to Caps Lock.
in reply to Simon Tatham

I have "x11vnc -display :0 -auth /var/run/lightdm/root/\:0 -R clear_all" in my bash history on soooo many VMs now.
in reply to Simon Tatham

I actually use and like to have Caps Lock.

But I believe the Debian installer still contains a change I made when I discovered that the Brazilian Portuguese keyboard layout has 106 keys, and / is on the 106th key - so I had to be able to switch out of it manually without needing to type any absolute paths!

in reply to Simon Tatham

I always remap Caps Lock -> Control which helps for Emacs key bindings
in reply to Simon Tatham

Apparently 1 in every 15200 keys I press on this laptop is capslock. 1 in 30400 of course, because of the toggling. Still higher than I'd expect. Recorder is at github.com/ralight/keycounts
in reply to Simon Tatham

you don't really need the *lowercase* version of it, I guess! 😀

Hm. Now wondering if you can bind capslock to "capslock off" for maximum "do what you want" 😀

in reply to Jack

@jackv ha, true, I could have made "xcapslock" implicitly mean "on", and "XCAPSLOCK" mean "off"!
@Jack
in reply to Simon Tatham

Exactly! I'm sure that's a horrible mistake SOMEHOW but I can't think why 😀
in reply to Jack

@jackv I think two reasons:

1. It assumes the _only_ use for the 'xcapslock' tool is to use it interactively on the command line. As soon as you find a use for the same tool in a script, you'll wish the syntax was more logical.

2. When you add the companion tool 'xnumlock', which has no analogous spelling variation in the command itself, you'll want both tools to have the same command-line syntax.

@Jack
in reply to Simon Tatham

Interesting. I have the caps lock key bound to compose in my GNOME session and it’s never been an issue for me, not when I used X and not now when I use Wayland.
Unknown parent

mastodon - Link to source
Tony Finch
@failedLyndonLaRouchite key lockouts exist, yes spkeyboards.com/collections/ac… (less reassuringly expensive suppliers exist, this is just one i knew of without searching)
in reply to Simon Tatham

My situation is remarkably similar. I also use xmodmap but I remap caps lock to the windows key and use it as a meta key with i3wm. I found when I use Remmina for RDP I often end up toggling caps lock somehow by accident. I suspect that when I'm inside the RDP session I use capslock to switch i3 work spaces and it must toggle caps lock at the same time while in the session. But somehow it also toggles on my host. I also made an alias `fixcapslock` that toggles it back off again.
in reply to Simon Tatham

How about a (soft) link in bin and doing a toLower() on the arguments?
Or no arguments and checking argv[0]s capitalization?
OK, i ges that is more work than an alias.
in reply to Kristian H. Kristensen

@krh if I had one of those, it would be mapped to 'mute' in voice calling applications! 'Sneeze pedal'.
in reply to Simon Tatham

Or this one for ctrl-alt-delete: mobspares.com/en-eu/products/p…
in reply to Alexandra Lanes

@ajlanes To be fair, pressing all three for ctrl-alt-delete does seem difficult with only two feet.
in reply to Simon Tatham

On my 60% the Caps Lock is F5 in Windows mode and Command-R in Mac Mode, because its a common useful shortcut for refresh, debug mode, and some other stuff for apps that I use more than I'd ever use Caps Lock. On the 40% the Caps Lock is Tab because the tab is Escape.
in reply to Simon Tatham

I map caps lock to escape and escape to caps lock. I'm never hitting the escape key by accident.

It's obviously great for vim, but even better for StarCraft.

in reply to Simon Tatham

I once accidentally xmodmapped all the letters to digit 1. Took some clicking to recover from that one.
in reply to Simon Tatham

It's a shame such a great spot on the keyboard has such a useless default key mapping. I've found it useful to map capslock to backspace but I have run into similar typing-before-the-rebind-script-runs issues.
in reply to Simon Tatham

My favorite use for caps lock is what the Neo2 keyboard layout uses it for: A modifier key, that when pressed maps “programming characters” like ( [ { to the home row for ergonomic typing.

See Layer 2 here en.wikipedia.org/wiki/Neo_(key…

P.S. Might be a bigger deal in German keyboard layout where these characters are very hard to reach 🤷‍♂️