Showing posts with label japanese keyboard. Show all posts
Showing posts with label japanese keyboard. Show all posts

Saturday, 17 April 2010

Japanese and English Keyboards - fun with evdev

I have been using Japanese keyboards now for many years and always make sure my laptops come with them. I like the layout and have become accustomed to it. However I was recently given a new Kinesis keyboard that has a US keyboard layout.

This new keyboard and nwo that evdev has become the flavour of the month when configuring keyboards under X make me write this post.

evdev and the default fdi keymap
However, the default fdi config does not play so nicely with Japanese keyboards. So here is my fdi keymap:


<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.keyboard">
<merge key="input.x11_driver" type="string">kbd</merge>
<merge key="input.x11_options.XkbRules" type="string">evdev</merge>
<merge key="input.x11_options.XkbLayout" type="string">jp</merge>
<merge key="input.x11_options.XkbModel" type="string">jp106</merge>
<merge key="input.x11_options.XkbOptions" type="string">ctrl:nocaps</merge>
<!-- If we're using Linux, we use evdev by default (falling back to keyboard otherwise). -->
<match key="/org/freedesktop/Hal/devices/computer:system.kernel.name"
string="Linux">
<merge key="input.x11_driver" type="string">evdev</merge>
</match>
</match>
</device>
</deviceinfo>


This works fine. Until you plug in another keyboard other than Japanese.

Keymap switching alias
To switch between Japanese and Keyboard layouts I have created the following aliases.

english='setxkbmap us'
japanese='setxkbmap jp'

This works fine except for the the "|\" key. Switching to English sees this key disappear all together. And if you have an international US keyboard the "|\" International Key becomes an "<>" key. So to fix this I have done the following.

# Create an ~/.Xmodmap file to remap keys 94 and 51 "|\"

keycode 94 = backslash bar
keycode 51 = backslash bar

# Change the above mentioned english alias.

english='setxkbmap us ; xmodmap ~/.Xmodmap'