So, to that end, I need to once again remap my Caps Lock key, but don't remember how to do it, and have to go back to my own more informative but longer blog post from a while back about remapping keys. But I figured it'd be a lot easier in the future (and possibly helpful to others) to write a post dedicated to disabling the Caps Lock key, and since a quick Google turned up wrong, dumb or temporary ways to do it, I will be doing myself, and perhaps you, a favor. I also thought it'd be good to have a post without all the blathering, but you see how well that worked out.
So, how to disable your Caps Lock key in Linux, the Right WayTM:
- Open (or more likely create) an .xmodmap file in your home directory (vi ~/.xmodmap)
- Add the line remove lock = Caps_Lock to it
- Save and close
Changes here will take effect on an X restart - if you want to disable it right now, you can run xmodmap -e "remove lock = Caps_Lock" in a terminal, and it will take effect for your current session. If this doesn't work, try also running xmodmap -e "keycode 66 =" to unmap the Caps Lock key completely - I had to do this on my work comptuer for some reason, despite all the "helpful" tutorials elsewhere on the internet. If you also find this to be the case, add keycode 66 = to your ~/.xmodmap as well. It's worth noting that the spaces around the equals sign are important in all of these commands. If for some really strange reason you don't have xmodmap installed, you'll have to do that first, of course, but it should come with just about any distro.
If you want to, like I did in my original post, remap Caps Lock to a more useful key (say, Esc, vim users?), you can do so by adding the following lines instead. Something like this is actually what I have in place on my personal laptop, as it's remapped to mod5, which gives me an extra key to use for things like Compiz mappings.
If you want to, like I did in my original post, remap Caps Lock to a more useful key (say, Esc, vim users?), you can do so by adding the following lines instead. Something like this is actually what I have in place on my personal laptop, as it's remapped to mod5, which gives me an extra key to use for things like Compiz mappings.
remove lock = Caps_LockThe first is what to replace Caps Lock, the second is an optional key for when you hit Shift+Caps Lock. {target keysym} is a semi-friendly name like "Escape" or "k", and is obtained from pulling up a terminal and either running xmodmap -pke and scanning/grepping through the resulting list or, my favorite, running xev and mashing they keys you want to remap to find the "(keysym 0x##, [keysym name])" in the output. A nifty way to do the latter is running xev | grep keysym - that will just spit out the needed line. With xev, just close the white box that comes up to stop things.
keycode 66 = {target keysym} {target keysym}
If you do want to know about xmodmap and the wonders it can work in rearranging your keyboard to your satisfaction, or you want to move your Caps Lock key, by all means check out my original blog post, which goes into things in more depth.
3 comments:
Thanks so much!! Everywhere I read that remove lock would work but it didn't. So frustrating! Then I found your site with the extra keycode 66 = command! Yay!
If I didnt use wx as my gui wrapper I would totally do that! I find that typing wx.FONTFAMILY_DEFAULT can get mighty tiring while holding down the shift key. Also, how else am I supposed to punctuate screaming everything I say at the top of my lungs?
This appears to be just what I was looking for. I have a eee pc 900 netbook and the caps lock key randomly gets activated with no way to disable it. Sometimes it'll be a little iffy and randomly activate/deactivate while typing which is especially annoying on linux, lol. This only happens when running X though, so I knew there had to be a solution. I've done what you recommended with xmodmap and so far, it seems to have worked. Thank you very much for posting this.
Post a Comment