Revisiting a bit of my X keymapping history

November 6, 2015

I started using X what is now a very long time ago, and unlike some people I've never had a complete break with my original X environment, one where I restarted my setup from scratch and threw away all of my old customizations. The natural result of this is that I have been carrying forward some historical decisions without actually ever really looking at them in a modern environment.

At some point in my life with X, one of my customizations became to swap the Backspace and Delete keys via xmodmap. My reason for doing this at the time was straightforward; Backspace was more convenient but generated ^H in various things, while I had set my Unix delete character to ^? (aka DEL) a very long time ago for reasons that seemed to make sense at the time. So things rumbled forwards, and when X programs gave me the choice I set them so that both the Backspace and the Delete keys would generate a DEL or otherwise act the same.

(It's possible that I was actually mistaken about this and my swapping Backspace and Delete was due to a misunderstanding. At any rate, I did it and this is what I can vaguely remember as my reasoning.)

Of course, not all things treat the two keys the same. Many editing fields in X programs use Backspace for 'delete-left' and Delete for 'delete-right', so I got thoroughly acclimatized to reaching off to the far key in order to actually backspace over things in those programs. And there were always a few other anomalies here and there that I just reflexively dealt with.

Recently, for reasons beyond the scope of this entry, I wound up in a situation without my usual Backspace/Delete swap. Much to my surprise, I didn't notice this in xterm, where everything continued just as before (most of how I noticed was realizing that I was deleting characters in a few X programs with the much more convenient Backspace key). While I wasn't paying attention, xterm had quietly decided to start turning both the Backspace and Delete keys into DEL (or at least into whatever your stty erase character is set to; I haven't investigated). Since I have urxvt and Gnome Terminal set up the same way, my xmodmap key swapping turns out to now be both unnecessary and actually a little bit inconvenient.

(Konsole isn't set up to do this, but then I never use it anyways. Sorry, KDE.)

So now I've removed that little bit of xmodmap work from my X dotfiles, and I'm taking a bit of a look at the other keymapping things I'm doing. I can tell you that making CapsLock into an additional Control key is definitely staying, though.

The whole exercise has been interesting and a little bit spooky. I haven't thought about my xmodmap stuff for quite a while now; after all, it worked, right? Yet either it quietly became unnecessary at some point or was never necessary in the first place. I'm sure there's other parts of my X environment that are the same way and I just haven't stumbled over them yet.

(My collection of X resources settings is a good candidate for this. I'm sure there's settings in there for programs that don't even exist any more.)

PS: The widespread use of GNU readline and similar line editing things in programs can make it a little bit hard to see just what characters your Backspace and Delete keys are generating, since by default I believe that readline et al do the same thing with ^H and DEL.

Comments on this page:

On top of making Caps Lock another control key, I have absolutely fallen in love with the xcape project. (Source code: It takes a modifier (like control) and will turn it into a regular key press if you simply tap the key by itself. Thus, I can make Caps Lock an escape (tapping the key) and a control (holding it with a pair) simultaneously.

I’m a big fan of making the Caps Lock key act like Escape when tapped and Control when held down. I use Karabiner’s “Control_L to Control_L (+ When you type Control_L only, send Escape)” mode on OS X.

Jason Weathered

By David at 2015-11-21 06:02:57:

I managed to drop all my old xmodmap hackery when I found out about xkb and that it could handle all the remappings I was using, such as caps as control, setting right alt as compose and swapping left alt and the windows key on my laptop. No more keycodes to find either :)

Although I don't think it does any cool tap-or-hold stuff (but I've not looked for that yet..)

(Brief reply due to reading on a phone to try and catch up with RSS backlog)

Written on 06 November 2015.
« SELinux's usability, illustrated once again
Why I (still) care about SELinux and its flaws »

Page tools: View Source, View Normal, Add Comment.
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Fri Nov 6 01:47:57 2015
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.