Emacs keybindings and ergonomics

NOTE (3/30/98): I don't use this stuff anymore. I use a Kinesis keyboard for my regular work, their thumb control keys are easier for me. You might still find it useful though.

DISCLAIMER: I'm not an ergonomicist, I'm not a doctor. I'm just a guy who happens to use computers a lot and whose wrists hurt from time to time. If you are experiencing pain in your hands, wrists, arms, etc, go see a doctor! You may also find the resources in The Typing Injury FAQ and Archive useful.

Here's the code I have available to improve the keybindings in some Unix software. Feel free to use and modify these as you see fit. They do what seems good to me, which might or might not be good for you.

The problem with emacs keybindings

I love emacs. I love most GNU software. I love it partly because it's good for hackers who want to move fast, get the stuff out of their head and into the computer. Unfortunately, sometimes speed is not so good for people. I've been doing Unix stuff for six years now, and in that time I've developed a mild but persistent problem with my wrists. In part, I blame the way emacs keybindings encourage me to use the keyboard.

The big problem for me is emacs reliance on chords, key sequences that require you to hold down two or more keys at once (Control-X, Meta-q, etc etc.) These are nice for a variety of reasons, and it avoids the necessity of modes (ala vi), but it also can be rough on your hands. The problem is if you have bad habits like I do, you tend to hit Control-X with one hand, curling your left hand in an unnatural position. Do this enough times and it's probably bad for you.

I can't solve the general problem of chorded sequences. I think the solution is to remove the concept of chords entirely, transform shift and control and meta into "sticky keys": first hit control, then move over and hit X. Alternately, most keyboards have these modifiers on both sides of the keyboard: if I could train myself to hold down control with the right hand, and hit X with the left, it wouldn't be so bad. Unfortunately, I can't train myself that way.

My solution

Fortunately, most modern GNU software allows you to reconfigure the binding between keyboard and function. And, fortunately, most modern terminals give you lots of extra keys: arrow keys, "home" and "end", function keys, etc. It takes a bit of work, but you can set up a lot of software so that you use these extra keys instead of chords.

My strategy has been to move the most common functions over to the extra keys, and at the same time to unbind the old control key combos. The second step might seem a bit strange, but I find it necessary. It's not enough for the arrow keys to work, the old control keys have to also not work or I'll brainlessly continue to use them.

My main effort has been to use the extra keys on an IBM-101 style keyboard. In particular, I want to always use the arrow keys to move around, Page Up and Page Down to scroll, Home to move to beginning of line, and End to move to end of line. In addition, I bind Insert to mean kill line, and Delete to mean delete-forward (strange, explained down below). Finally, I bind the function keys to do useful things in emacs. With these bindings, I've eliminated the majority of my control key combinations: no more Control-b, Control-n, Control-p, Control-f, etc etc etc.

A special note about Home and End - these keysequences are not standard: I have four different versions of them (two xterms, linux console, rxvt). Did the vt100 not have these keys? Anyway, I've handled every case I know about. See .inputrc for more details.

Naturally, these bindings is not a panacea for RSIs. It's even possible that they will make things worse for you, or move the problem. The rebindings here seem to help me, and I hope they can help you.

The software

I've made several small configuration files to perform these keybindings in much of the software I use. I've placed these online for you to use, customize, modify, or throw away. Any ideas about how to improve this stuff are welcome.

ergomap.el
Ergomap.el is a small lisp library that redefines keys on your keyboard for greater friendliness. It defines lisp functions that move keybindings from one key to another, and then uses those functions to move the most common chorded keys to their new locations. To use it, download ergomap.el into your emacs load path and put the line (load-library "ergomap") somewhere in your .emacs, preferably at the end, then call (ergomap-remap-keyboard). The function keys here are a bit arbitrary, redefine them as they suit you.
.inputrc
.inputrc is the file GNU readline uses to configure its keyboard bindings. Any program that uses GNU readline will pick up these bindings: bash and gdb, for instance. The bindings are much the same as in ergomap.el, with some extra hacks to capture all the variations on Home and End. Drop this file in as $HOME/.inputrc to get the new bindings.
.ircrc
I wish IRC II would just use GNU readline, but they don't, so I have separate bindings for IRC. The f13-means-delete binding isn't there, because the IRC mechanism for binding keys is so broken I couldn't do it.
xterm.el
Emacs loads the lisp library "term/$TERM.el" when you start it up in tty mode. If $TERM=xterm, though, there's no xterm.el. I've written one that loads the vt100 bindings and then defines [home] and [end].
.xmodmaprc
Finally, an input file for xmodmap that effects a slight change in the default X bindings. You may or may not think this is a good idea: no flames please, the religious war between Delete and BackSpace is ridiculous. I remap BackSpace (the big key above Enter) to mean Delete, because you almost never mean BackSpace (except in new Motifish software, sigh). I then remap Delete (the little key above the arrow keys) to mean F13: a weird choice, but it's a free keysym. ergomap.el and .inputrc then bind F13 to mean delete forward, the old DOS meaning of Delete. Note that the keycode your Delete key sends might not be the same as mine: run the program "xev" and hit the Delete key in the window to see what keycode it sends. Better yet, find a copy of jwz's excellent xkeycaps program.

Nelson Minar Created: August 24, 1995
<nelson@media.mit.edu> Updated: March 30, 1998