Ruby with a Japanese keyboard
Wed 09 May 2007
Now that I am leaving Japan, I have started taking notice of the more esoteric items that I will miss. One is programming in Ruby on a Japanese keyboard.
At work I use the Japanese version of the Apple Pro Keyboard, which makes a few deviations from the standard JIS keyboard. Japanese keyboards are qwerty, so the alphanumeric characters are entered the same way as on a US keyboard. What makes the keyboard particularly suited to Ruby is the placement of the Ruby “punctuation” keys: colon, operators, underscore, and the like.

Non-alphanumeric characters used in Ruby programming include
( ) [ ] { } | : @ $ # % _ \ . , ” ‘ ? ! = + - * / < > ^ & ~ ;
These characters can be divided into three categories
Equivalent on both keyboards
Most of these characters are in the same place on both a Japanese and a US keyboard, and on both some require using shift as a modifier key.
( ) = - / # $ % & [ ] { } | ? ! , . < > ~
While the placement of the keys for entering some of these characters (e.g., tilde) is different, they are not more or less difficult to type.
Easier on a Japanese keyboard
These are the keys I will miss. What I like about them are their placement and that they can be typed without the use of a modifier key.
: _ @
Okay, so it’s only three characters, but these three are used a lot in Ruby. They are all entered just using your right pinkie finger and without moving your wrist. On a US keyboard, you enter a colon using ‘⇧–;’ (that’s SHIFT and semi-colon), while commercial-at is ‘⇧–2′. Conveniently, the underscore on an Apple Pro Keyboard is placed immediately to the left of the right-hand shift key. On a US keyboard, you have to hold down the shift key while reaching up next to the delete button. That’s a long stretch for such a commonly used character.

Other characters, while they still require a modifier key (shift), have a different placement
+ *
Easier on a US keyboard
The two that really bug me are
' "
since not only is the placement different, but they both require a modifier key. While this isn’t so bad when programming, I find it annoying while typing English.

The other slightly awkward key is backslash. Its placement is approximately the same, but it requires a different modifier key (option instead of shift). This isn’t so bad for Ruby except when you are writing regular expressions or escape characters, but I use that character a lot on the command line.

Other blessings, other curses
For coding Ruby, the Japanese keyboard’s ergonomic superiority is probably not a coincidence. The placement of the prime and double-prime “quotation mark” keys is only a slight hindrance to using the keyboard for English. Another difference between US and Japanese keyboards is that the caps lock and control keys are swapped. This is excellent for vim, since control is an oft-used modifier for entering commands (that there is a separate colon key is also useful). Yet it is annoying for key combos that require more than one modifier key, common in programs like TextMate.
Since I do most of my programming at work (my home computer has a standard US keyboard) I have become quite accustomed to using a Japanese keyboard for most tasks. Whenever I program Ruby I will sorely miss this keyboard layout.