How many years have you been making the tedious stretch for Ctrl and Esc keys?  Maybe you’ve gone so far as choosing workflows that don’t require them much, maybe without even realizing it.  That would be sad.  You just can’t use vim or emacs (or even web browsers) without them.*  I stopped the stretching a long time ago.  If you haven’t fixed this yet, you’re either crippling yourself, or being sub-optimally productive.  There are various ways to this and eliminate the stretching — I’ll touch on a couple so you can relieve your aching left wrist.

Easiest way

Almost a decade ago the Happy Hacking keyboard came out.  This was a brilliant product that I can’t believe hasn’t altogether replaced the PC layout and monster keyboard footprint.  I’ve had a few through the years, and I highly recommend them.  They have been at the $70 mark all along though, so I’ve decided to stop buying them, when commodity keyboards are a dime a dozen, even the small footprinted ones.  I’ve also had the legendary OMNIKEY (and maintain it as a keepsake), which is hands down the best keyboard ever made (clickety-click-clack).  But they’re even pre-PS/2, so probably impossible to get working with USB (let me know if you’ve done it!).  So that’s the first and simplest solution if you’ve got the budget: spend the money to get a great UNIX keyboard.


Harder, cheaper way (still easy enough)

But you probably work at various machines, and everyone has a budget.  And sometimes we have to use that silly laptop keyboard.  So now you’re looking at a keyboard reconfig.  If you just want to make CapsLock go away (not a bad idea) and put Ctrl where it’s supposed to be (left of ‘A‘), you can use GNOME to swap them.  Something like: System -> Preferences -> Keyboard -> Layouts -> Other Options -> Ctrl Key Position -> Make CapsLock an additional Ctrl.  There’s also some swapping options, but overall the options there are pretty rigid and don’t get you all the way there.  So don’t bother with this approach, unless you only want to fix the Ctrl key.

What you really need is xkeycaps.  You can install it in a Debian-based system with apt-get install xkeycaps.  Other distros should also make it easy.  It’s not the most intuitive tool to use if you haven’t played with it before (that’s why I’m writing this), so I’ll walk you through what I did with it.  BTW, it’s an ancient tool, from the legendary hacker Jamie Zawinski.

Some keyboard layouts vary slightly from the 104-key standard, but I believe you can get any cheapo or absurd laptop layout to do the right thing with a little experimentation.  We’re going to be reassigning some keys.  It’s crucial that Esc is in a friendly spot — that probably means just left of your 1 key.  Even on a small keyboard with an Esc just one close row up, it’s still too far; you’ve gotta try putting it in the optimal spot.  But then you’ll be losing `~ (or something)!  What a dilemma!  You can’t code without those.  Some will disagree with me here, but I have found the RightAlt key to be a great, easily right-thumb-accessible, unused key, so that’s what I now use for `~RightAlt is a sad loss if you’ve got a crappy mouse (since RightAlt-LeftArrow have been the canonical browser back-button), but that may be the subject of another article.  Just get a 5-button or tilt-wheel mouse; recent Ubuntus do the right thing with the extra buttons, in my experience.  So we’ll proceed here to use RightAlt as the `~ replacement.  And we’ll be throwing away the original inaccessible Esc.  That top Function key row is off limits for touch-typists.

You can scramble a bunch of keys around as your see fit for your MO.  Here’s the process I used (as close as I can recall) for the Ctrl, Esc, `~ reassignments I’ve been describing:

  • Fire it up from a terminal: xkeycaps
  • Just say ‘ok’ on the first screen which should default to the right ‘PC’ layout.
  • Hover over the Esc key and notice the KeySym at the top, indicating you’ve looking at Esc.  If you screw anything up, this is the place to see it.
  • Move away and physically press Esc and watch it light up on the screen.  Now you can verify any key’s position, which you want to do for any changing keys.
  • Make sure all the keys we care about are mapping to the right location.  I found that RightAlt on my wacky keyboard was actually mapping to my number pad’s Enter.  So figure out what your RightAlt is by pressing it.  That’s what we’ll reassign.
  • Make the first reassignment.  Right-click-hold on `~ and select Duplicate key.  Then click on RightAlt (or its equivalent).  Now you’ve got another `~ key! (and you can probably figure out the rest).
  • Now we can reassign the original `~ to be an Esc.
  • Do the same Duplicate key trick to make the original Esc duplicated over `~.
  • Finally, do that process one more time assigning the original Ctrl (crazy bottom-left postion) over the top of CapsLock.  Added bonus: no more CapsLock key (remedy that if you want).
  • Write out the new layout with the Write Output button (just the Changed Keys is enough).
  • Now you’ve got a new ~/.xmodmap-machinename file.  I believe it’s already been activated at this point, or at least xkeycaps has done some magic.
  • You’re done.  You might find that some things are not working at this point.  You can always restart xkeycaps and restore to defaults.  But you’ve likely got things right, and just need to log out of X and log back in.  My arrow keys broke when I did this before restarting X.
  • Every time you start up X you’ll need to run xmodmap ~/.xmodmap-machinename.  But Ubuntu (or something) actually automatically detected my new .xmodmap and prompted me to ask if I wanted to use it.  That was friendly!
  • Use some white-out or tape to relabel your new keys. (optional)

Whew!  That was quite a few steps.  Fortunately, it’s just a one time setup, and subsequent uses of xmodmap at login are trivial (put it  in your .bash_profile or equivalent if not prompted; use $(uname -n) to make it flexible for a shared profile).  I hope you’ve got it working now.  You can leave a comment if you’re having any trouble with the steps and maybe I (or someone) will be able to figure it out.  Breathe a sigh of relief as you re-train your fingers to stop stretching.

I can no longer type without the hack described here.  You can probably alter it for any machine you’re on and any of your own different preferences.  I’m also considering making Ctrl-J a permanent duplicate for Enter.

I should also add a rant for why this article and tools need to exist: Shame on IBM and Microsoft and all the others involved for being such layout idiots and costing the world so much in ongoing CTS healthcare costs.  Especially when the optimal layout was already well-known and widely used.  Remind you of anything (backslash path separator, another ergonomic impropriety; plus countless others)?  It’s really interesting to just stare down at the PC location of Ctrl and Esc, two essential keys probably both in the top 5. They couldn’t possible have been put in less convenient places. Well, maybe they were just taking the QWERTY model of slowing down typists to the next level.  I’m surprised they didn’t think to move Shift up to F5 and Enter over to ScrollLock.

Be sure to thank Jamie for saving your wrist and adding years of screen time to your life.

* Furthermore, I make the typical assumption you’re using some *NIX variant.  Why else would you be here?  But if you’re using Windows or a Mac there are some other tools floating around that will help you customize your keyboard layout; I’m sure they’ll be different from xkeycaps.  Whether hacker or not, anyone can benefit by making these changes.

Tags: , , ,

11 Responses to “Make a PC Keyboard UNIX-Friendly”

  1. [...] here: Are YOU Looking for TOSHIBA LAPTOP COMPUTERS Laptop Computers Tips Laptop Computers GuideMake a PC Keyboard UNIXFriendly Micah Elliott More infos are available here: Make a PC Keyboard UNIXFriendly Micah [...]

  2. Nice article! I already employed some mods, and I'm now going to try some of your suggestions.

    By the way, it's perfectly ok to use an old AT keyboard on modern USB computers. I'm a proud owner of a pre-2000 ergomic keyboard:

    http://support.ap.dell.com/sup.....il_…

    This happens to be much better than many modern curve keyboards; MS-NEK 4000, for instance, sports many small and different-sized keys (not just for Enter/Backspace and so on, different letters may just have different sizes!).

    By the way, I just use a cheap AT-to-ps2 adapter (it's worth something like EUR 3,00 at my local electronics store), and then connect a ps2-to-usb adapter to it. The latter is a bit more expensive, around EUR 15,00, but it shouldn' t be a real issue if you need such keyboard.

  3. Nice article! I already employed some mods, and I'm now going to try some of your suggestions.

    By the way, it's perfectly ok to use an old AT keyboard on modern USB computers. I'm a proud owner of a pre-2000 ergomic keyboard:

    http://support.ap.dell.com/sup.....il_…

    This happens to be much better than many modern curve keyboards; MS-NEK 4000, for instance, sports many small and different-sized keys (not just for Enter/Backspace and so on, different letters may just have different sizes!).

    By the way, I just use a cheap AT-to-ps2 adapter (it's worth something like EUR 3,00 at my local electronics store), and then connect a ps2-to-usb adapter to it. The latter is a bit more expensive, around EUR 15,00, but it shouldn' t be a real issue if you need such keyboard.

  4. Hi Alan — I just ordered a PS/2-to-USB converter in hopes of bringing my ancient OmniKey back to life. Thanks for the suggestion. I already have the AT-to-PS/2 converter (they just seem to be wire-crossers). Anxious to see if the double conversion will work. If not, I've got a PS/2 HHK lying around that I'll put back to work. Your ergo looks pretty nice. I haven't spent enough time with one to decide if I like the feel or not. Sure glad to see some hardware of antiquity sticking with us.

  5. Leonardo says:

    I use the Ctrl key in its normal PC position without moving a finger. I guess I have big hands, but I can just rest the edge of my palm on the Ctrl key, and still reach the whole left side of the keyboard with my fingers.

    Although I do viciously hate the capslock key. I'll be hacking away happily in vim, and accidentally hit capslock, and before I can tell what's going on, I completely deface my buffer and my train of though is violently derailed.

  6. Leonardo says:

    I use the Ctrl key in its normal PC position without moving a finger. I guess I have big hands, but I can just rest the edge of my palm on the Ctrl key, and still reach the whole left side of the keyboard with my fingers.

    Although I do viciously hate the capslock key. I'll be hacking away happily in vim, and accidentally hit capslock, and before I can tell what's going on, I completely deface my buffer and my train of though is violently derailed.

  7. I use the lot the "palm" as well in order to reach control… I guess I got THAT used to it that I didn't remember mentioning. I still think CapsLock-To-Ctrl is useful in some contexts, e.g. capslock + function keys.

  8. That's really impressive! I suppose quite a few people must be able to use Ctrl in that crazy spot. I actually get a little wrist-sore during a heavy vim hacking session even with Ctrl right next to 'a' (the most convenient spot I can imagine). So maybe I'm a bit sensitive. I've even considered getting one of those assignable foot pedals and using it for Ctrl (not sure what the other pedal would work best for). But who actually keeps their feet in a consistent enough spot for a foot pedal?! And yes, CAPS LOCK IS A HUGE WART AND I HAVE NO IDEA WHY IT EXISTS. That's what what '[Esc]gU[movement]' is for, right?

  9. Leonardo says:

    Yes, capslock is a waste of keyboard space and it also probably accounts for 80% of the planet's bad written style in the last 40 years.

    Try resting your forearms and hands at 45 degrees inward with respect to the keyboard. I sit the lower left edge of my palm on the Ctrl key, and my pinkie points to the 3 or 4 keys. That way I don't need to move my wrists at all, and I can easily cover the whole keyboard.

    And while we're geeking out about keys: I absolutely love bash/readline's Ctrl- combinations. There's even Ctrl-H, Ctrl-J and Ctrl-I for backspace, enter and tab respectively. It's like my happy playground which I never have to leave because it has all the toys I ever want.

  10. Leonardo says:

    Yes, capslock is a waste of keyboard space and it also probably accounts for 80% of the planet's bad written style in the last 40 years.

    Try resting your forearms and hands at 45 degrees inward with respect to the keyboard. I sit the lower left edge of my palm on the Ctrl key, and my pinkie points to the 3 or 4 keys. That way I don't need to move my wrists at all, and I can easily cover the whole keyboard.

    And while we're geeking out about keys: I absolutely love bash/readline's Ctrl- combinations. There's even Ctrl-H, Ctrl-J and Ctrl-I for backspace, enter and tab respectively. It's like my happy playground which I never have to leave because it has all the toys I ever want.

  11. Oh, I see. Your palm?! Cool idea. Makes sense. I use Ctrl-[everything] in terminals. I don't see many other people doing it though, and I'm not sure why. Enter is just way too far away. Adopted those many years ago. I actually use vi-mode in bash/zsh/ipython/whatever, wherever readline goes I'm happy. I find myself hitting Ctrl-J in Firefox all the time and really messing up my flow.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>