I use a pretty generic US keyboard, which comes with the normal characters, two "Windows" keys, and a "Menu" key. This is clearly not enough to enter everything I might want to write.
Keyboard setup in the Linux console and in X are very different. Of course, the Linux console lacks the support X does for extended fonts anyway, so there's not much use in running in console mode if you want these extra characters.
In X, run
xev to find the keycode of a key. Hit the relevant key when the mouse is over the xev window and watch the console. For example, the "Menu" key on my keyboard (which is to the right of the spacebar: alt, windows, menu, ctrl) is keycode 116.
The commands listed below are
xmodmap commands. You can run them as
xmodmap -e 'command'. Put them in your
~/.xsession to make the settings persist.
You can use a "mode switch" key to assign more than two meanings to each of your keys. Right now, a key like "d" produces a "d" when pressed normally, and a "D" when pressed while holding shift. How about making it also usable for producing a "degree" symbol?
First, map some key to "Mode_switch", which works as a sort of extended "Shift" key. I used my right alt, keycode 113. Then map extra keys, following the pattern here:
keycode 113 = Mode_switch keysym d = d NoSymbol degree NoSymbol keysym e = e NoSymbol EuroSign NoSymbol keysym m = m NoSymbol emdash mu keysym n = n NoSymbol endash NoSymbol keycode 34 = bracketleft braceleft leftsinglequotemark leftdoublequotemark keycode 35 = bracketright braceright rightsinglequotemark rightdoublequotemark keysym space = space NoSymbol nobreakspace NoSymbol keysym minus = minus underscore 0x01002212 NoSymbol
For example, right alt + left bracket now produces a single left quote, while holding shift and hitting that produces a double left quote. Also noteworthy are the em and en dashes. (Adapted from an email from Markus Kuhn to the x18n mailing list.)
You can use a "compose" key to get extra characters while keeping your existing keyboard map. For example, I can type [Compose]["][u] and I get a u with an umlaut, if I were in the mood to type German. Setting up your compose key is simple: run
xmodmap to map a key to "Multi_key":
xmodmap -e 'keycode xx = Multi_key'
As with almost everything Japanese, Japanese input is more difficult.
Japanese input boils down to a few separate layers:
- The backend (canna seems popular) takes strings of hiragana and tries to figure out which kanji you meant.
- The frontend (kinput2 is common when you're using X) interfaces your user interface with the backend (for example, by popping up a list of the candidate matches).
- Now, each program you run needs to know to interface with the input layer, and
kinput2is only for Japanese— Chinese has its own system (called
xcin). So instead there's an abstraction layer on top of
kinput2called XIM ("X Input Method") that's used in X. So finally, your actual program needs to work with XIM (which will allow it to simultaneously work with Chinese, etc.).
Once you've installed all of this software, you need some more configuration:
- Tell X to use kinput2 for with XIM. Into
~/.bashrc, or whatever sets up your environment:
Make sure you have Japanese locales set up. On Debian, use
You need at least
kinput2 must be run with an EUC-JP locale:
LANG=ja_JP.EUC-JP kinput2 &
And then run your program (mlterm is a good terminal) with a Japanese locale (I like UTF-8, myself):
LANG=ja_JP.UTF-8 someprogram &
Finally, hit shift-space to flip into Japanese and hit it again to exit. Type using romanji, then hit space to convert it to kanji (and space to cycle through the candidates), and hit enter when you've completed a word.
im-ja is a Japanese input module for GTK2 that uses canna directly. This circumvents the potential problems with kinput2 and XIM and would (in theory) integrate better. From my tests, it seems incomplete, but it's a good project to keep your eye on.Evan Martin, firstname.lastname@example.org