Protecting your hands as a programmer

Status: Done, but occasionally revised
Confidence: Likely

A couple Wednesdays ago, my hands started hurting. By Thursday afternoon, I had to leave work early because typing was too painful to concentrate. I didn’t touch a computer again until Monday morning, by which point I could work a partial day. Now, several weeks later, I can work a full day, but the joints in my hands still feel stiff.

I suspect that my troubles arose from playing the violin, or rather, from not playing the violin. I was a violinist before I ever touched a computer, and my hands have always been very strong. But over the last couple of years, after I had kids, I haven’t been playing, and all that muscle that protected me from my poor typing habits all these years was no longer there do so. So I have had to reevaluate the ergonomics of how I interact with computers.

There is almost no good information on computer ergonomics online, so, in hopes that I’ll save someone who doesn’t have my background in studying body mechanics from chronic hand pain, here’s how to avoid suffering.

When working on body mechanics, start from the ground, work your way up through the core, and then out through the extremities involved. Your neutral position should have the body facing directly towards the monitor. Don’t twist your spine. Don’t cross your legs. If you’re sitting, make sure that your chair provides a stable support, like a piano bench. Your torso should be vertical.

Let your hands hang loosely at your sides. Then bend them at the elbow until your forearms are level. Your hands will naturally be in front of your belly unless your engage muscles in your back to rotate your arms out. This is your typing position: shoulder relaxed, upper arms vertical, forearms horizontal and pointing inward, wrists straight, hands meeting in front of your belly. Now place your finger on a surface at that height (which is where your desk should be), and, keeping your wrists straight, apply downward pressure on the desk. Don’t hike yourself up to shove your whole weight on it, just press. The force in your arms should be mostly in your wrists, not your elbows. If your elbows are working harder than your wrists, lean back so your torso is vertical. Now arrange your body to make that pushing strong while your body remains relaxed. Using a keyboard and mouse is about applying pressure downward to a surface with your fingers, so getting this position right is essential.

Now place your keyboard under your hands where they rest in front on your belly. Don’t reach out for the keyboard. Next, let’s position the mouse. Rotate your right arm (substitute left for right in all this if you use your mouse in the left hand) out, keeping the upper arm relaxed and vertical and the forearm horizontal. Until your arm reaches straight out in front of you, there is no strain across it. When you reach that point, you will feel tension on the inside of the elbow. Try extending your hand along the table as though moving the mouse pointer up on the screen. Try it with the arm rotated inside of straight in front of you and outside. Outside should feel harder. The muscle rotating the arm is on the outside of the arm. The muscle extending the arm is on the inside. When the arm is rotated out, you are making those muscles work against each other. So you want your mouse just beyond the keyboard where you can reach it by rotating your arm, but not rotating it into the regime where your muscles oppose. This may require getting a keyboard without an attached numeric keypad.

At this point we have placed the keyboard and the mouse. Now how do we operate them? Pick up your hand and drop it on the desk. That is the force you will use, but articulated to work with your individual fingers. This is also why I had you press on your desk above. That exercise gets your body in a position where you can stably drop and absorb the force of the impact.

To press an individual key with one finger, drop the hand with the other fingers curled just enough to not strike additional keys. Initially, you will drop your hand for every keystroke, but as you adjust to this motion, you will naturally start to roll your hand through some sequential strokes to get multiple strokes on one drop for certain combinations of keys. Incidentally, this is what the Dvorak keyboard layout does or you: it makes more keys line up in easily rolled sequences when typing English text. Based on my experience, though, the cost of learning it didn’t justify the time.

Now, when you strike a key, the key travels down and brings your finger to a stop. Your finger has to absorb the impact of that stop. The key principle of absorbing impact is to do so along the direction of movement of a joint, and in the middle of the joint’s range of motion. So you want your finger joints slightly curled when you hit. You want your knuckle bent so the fingers are below the plane of your hand. Starting with a flat knuckle would bend it backwards, which makes that joint work at the end of its range of motion. Similarly, the thumb should be kept next to the hand when striking the space bar with all of its joints slightly curved. The outside half of the end of the thumb strikes the key, not the side of the thumb.

One thing you will immediately notice is that your wrists are in the air. The have to be in order for you to be able to drop. If you bring the keyboard in to the neutral position in front of your body, you will not need the support of a wrist rest.

Your wrists should be straight as you type. If you don’t have narrow shoulders, this will make you angle your hands relative to a normal keyboard, which forces you to bend your ring and pinky fingers much more than your index and middle fingers in order to place them on the home row. This takes the joints of the ring and pinky fingers out of the center of their range of motion, which stresses them. Most humans actually need a split keyboard.

Even better than a split keyboard is a tented keyboard, where the two halves are separated and meet up in the air in the middle like an A-frame tent. Try resting your wrists on your desk without the keyboard and relaxing them. Your palms don’t lie flat on the deks. Your hands are rotated up at an angle. Ideally your keyboard would match that.

You may have to compromise a bit on this. I measured the relaxed angle of my hands and adjusted my keyboard accordingly, but it was high enough that I couldn’t see the function keys easily, so the pieces of the keyboard I do not touch type became nearly inaccessible. I have it around 25 degrees from horizontal at the moment, but I keep messing with it.

Also, since you are impacting keys repeatedly, for the sake of your fingers, you want the softest impact that you can get. That has two parts: the force required to depress the key, and how far it travels. Ideally you want a long travel with little force. Short travel, such as what most laptop chiclet keyboards provide today, jars your joints even with low force. Heavy force, such as most mechanical switch keyboards provide, makes your finger joints bear unnecessary load.

So you need a soft impact, split keyboard, and you type by dropping your hand and absorbing the impact of striking the key in the middle of the range of motion of your fingers. But there are some common habits among programmers that sabotage this clean mechanics, and that you should break immediately.

The first is hitting chords of keys with one hand. If you are holding a key down ith one finger, you cannot drop the hand to get a strike. Most chords involve holding down shift or control at the edge of the keyboard with the pinky, which forces you to contort your hand to reach the rest of the chord. This causes damage so universally that its effect is known as “Emacs pinky,” after Emacs’s default keybindings that involve ridiculous chords. It is almost as bad with the thumb, since you end up pushing laterally across its joints to hold a key down.

If you need a chord, practice typing it with two hands. One hand holds the control keys. The other hand presses the letters to invoke the chord. This takes a little getting used to, but it pays off in your hands hurting less.

A few chords end up being easier and not putting strain on. For example, if you make your caps lock key into a control key, Ctrl+w is a fairly painless chord. With a Ctrl key at the bottom left, Ctrl+x, c, and v are also relatively painless. Basically, any key you can reach without straining your hand from the control key is likely to be okay.

If you get rid of most of your chords, how do you do anything? There is a certain fetish for knowing lots of obscure keyboard commands in old text editors in the programming world. The simple answer is that you don’t need most of them. There are three distinct modes of working with an editor. You are either entering text, writing text transforming programs such as macros (which don’t have ergonomic implications), or moving around a screen and editing existing text. When you are entering text, you type the characters, one after another, or delete backwards to correct a mistake. Backspace is too slow, but I have found that if I have backspace and backspace to the beginning of the last word, that takes care of all my corrections in a forward stream of text.

When you are editing, you move at random. You move the cursor to some point, enter a character or two, select another region and cut it, then place the cursor and paste it. The majority of the task is placing the cursor or selecting a region. And this is best done with the mouse. It is faster than using even sophisticated key bindings, it doesn’t require you to learn those key bindings, and it requires less engagement of your higher mental processes. This is heresy in many circles, but the data is clear. If your editor doesn’t let you easily place the cursor or select regions with the mouse, replace it.

There is also a common perception that the mouse causes repetitive stress injury. This is because it has in many people who are using awful mice and who are using them incorrectly.

First, you put your hand on the mouse. Your hand should be tilted between thirty and forty five degrees from flat. If you roll it to flat, you can feel tension in your forearm, which will pull against you when moving the mouse or striking its buttons. Similarly, if you rotate it to vertical you will feel some tension, though less. Find the point in the middle where there is a minimum of tension.

You don’t hold the mouse. The only reason your thumb touches the mouse is so you don’t have to hold it up in the air. The same is true of your pinky. The weight of your hand on the top of the mouse should be enough to move it effortlessly. If not you need a better mouse pad and possibly a better mouse.

You never put your palm on the mouse. You strike mouse buttons with the same principle as you strike keys on the keyboard: the whole arm’s weight drops and the finger absorbs the impact. This is impossible if your palm is resting on the mouse. Mouse keys are much easier to press than keys on the keyboard, and you need enough contact of your hand with the top of the mouse to be able to move it, so the best compromise seems to be to put your fingers from your knuckles down on the mouse. The main pressure gets applied at the first joint closest to the knuckle, so the knuckle has to do all the absorbing, and it must be curled a little and not flat, or, heaven forbid, bent backwards to get your fingertips onto the mouse buttons.

Don’t try to click the scroll wheel as a button. There is no way to do this that is good for your hands. If you need more than two buttons, find a mouse that has additional buttons.

If you spent a lot of time playing first person shooters at some point in your life, you need to make another adjustment for your mouse. Turn the mouse speed way down and the acceleration up. The speed when moving slowly will seem almost absurdly slow, but it makes pointing at regions of text easy. Rely on the acceleration to move long distances on the screen.

(Update: (2015-9-8) One of my readers wrote into recommend Apple’s track pads. I have used them since 2001 when I got my first Apple laptop. They unfortunately are not ergonomically okay. You either tap to click on the surface of the trackpad, which involves impact on a nonyielding surface with your finger, or you click with on the bottom edge of the track pad which travels somewhat. The problem is how to drag and drop. You either click and hold with your thumb at the bottom of the track pad while moving your fingers above, which has the same problems as chording on the keyboard, or you tap and then drag on the surface of the trackpad, which involves impacting your finger on an unyielding surface. You could press the bottom with a finger of one hand while moving the cursor with fingers of the other hand, but then you can’t use the other hand for executing commands, such as copy and paste, or much more advanced operations in Adobe’s tools or Ashlar Vellum’s CAD program.)

If your keyboard and mouse won’t let you use good mechanics, you need to replace them. You need to get your desk set up so you can be in a neutral position. And you need to break bad habits and reconfigure your editor. And you may want to go further. For example, most computer provide ‘sticky keys’ under the accessibility options, which make shift, control, and other modifiers persist until the next keystroke without holding them down. This removes all chording from the keyboard, all holding down of keys. This seems bizarre at first, but I have quickly grown to love it, since holding down keys is surprisingly stressful for the hands. Having an on-screen indicator of what modifiers are pressed is vital to make this work, though.

Similarly, I turned off key repeats. The only key I ever wanted to repeat was backspace, and with backspace word right to hand I find I don’t miss repeating backspace.

So, a checklist for fixing your body mechanics and saving your hands:

(Update: (2015-9-8) As my hands have recovered, I have been able to get away with things like typing on my laptop and using my trackpad again, but now that I have focused on this, I can feel the strain it’s causing. If your hands are healthy and strong, you can get away with ignoring most of this. If you start having problems, remember this stuff. It will make a lot of difference.)