My keyboard layout

I'm a bit particular about my keyboard layout. It's a slightly modified variant of the Dvorak layout. The significant differences are that the key to the left of 'a' (usually labelled Caps Lock) is the open parenthesis (open curly brace if shifted), the key to the right of the Dvorak 's' key is the close parenthesis and brace, and the key to the right of that is - and _. Shift-9 and Shift-0 are [ and ].

This assumes a UK keyboard with enough keys in the home row to fit them all in. The original idea was that for programming the brackets and braces are used often enough to go on the home row.

One slight wrinkle is that the key to the right of Backspace (usually labelled '=') generates the same keys as the Caps Lock. This is for two reasons:

I don't claim that this keyboard is necessarily right for anybody else except me, but I've got used to it over the years. This page is primarily for my own benefit to remind me about how to get it working on various operating systems.

Linux (console)

This used to be done with a PC scancode keymap: dvorak-boottime.kmap.gz is a file suitable for use as /etc/console/boottime.kmap.gz. Since that file uses scancodes, it'll only work for PC keyboards. However these days Debian uses an XKB mapping for the console, so you should just do the XKB stuff below, and then edit /etc/default/keyboard to have XKBLAYOUT="pmm" in it, and run service keyboard-setup restart to cause a reread of it.

Linux (xmodmap)

keysym.dvorak.pc can be fed to xmodmap to remap all the keys. It uses scancodes so it's safe to run it whatever your current keyboard layout is, but it has to be a standard PC keyboard.

Linux (XKB)

xmodmap is generally considered deprecated these days in favour of the new shiny and only barely documented XKB subsystem. xkb_symbols_pmm is a file you can put in /usr/share/X11/xkb/symbols/pmm. You'll need to add it to the list of keyboards XKB knows about:

Then it ought to show up in the keyboard config dialogs for Gnome et al., or you can just run setxkbmap pmm in your .xsession.

NB: There is also (on Ubuntu) a base.{xml,lst}, and some other files which are symlinks to them. I don't know why evdev.{xml,lst} isn't also a symlink; it seems to be the one that is actually used. Probably better to put the changes into both files.

Windows

For ages I never had a mapping for Windows. I've finally jumped through enough hoops to get it all working. The key is Microsoft's Keyboard Layout Creator. You can feed it this source file, or you could just be lazy and install the resulting .msi file. You'll then need to select this keyboard layout and make it the default.

The other part of the puzzle is remapping Caps Lock to generate the '=' scancode (see above). You'll need the kmapper utility. You can feed it caps-is-equals.kmp and tell it to save to the registry (needs a reboot). Or you can do it by hand: click on the 'Caps Lock' button, then on the + = line. It should say:

Mapping Caps Lock(Key) to + =(Function) - (3A - D)

NB: this is just a nicer interface to a registry setting, so it's not a disaster if the kmapper utility disappears, but just in case I've got a copy of it here.

Kinesis Keyboard (hardware)

These days I use the Kinesis Advantage USB keyboard, because I think they're better for my RSI. I tweak the keyboard a bit using its built in remapping facilities. The result is only intended to be used with the keyboard mapping given above, really. Here's how it goes:

First, hold down = and tap w to get 'windows mode' (with windows aka hyper key). Next, we move some of the punctuation around:

Keypad Progrm+F12 Break Keypad [ [ ` ` = = CapsLock Down Up Up Down Progrm+F12
(in this sequence keys are referred to according to what is printed on the keycap)

This also remaps the CapsLock key to generate keycode 21 (the = key on a uk qwerty layout) because the kinesis insists on disabling key repeat on capslock. So the linux xmodmap file has to treat 21 like capslock (ie "parenleft braceleft"). This key isn't really used in our custom mapping on a normal keyboard so it's not a problem to have it mapped like that in all situations.

However, one minor gotcha with that mapping is that the keys used by the keyboard for the `=w', '=s' etc combinations follow the mappings the keyboard knows about; so once this mapping has been done you need to press 'capslock+s' for status, and so on. Watch out for accidentally hitting things...

Finally, it swaps up and down arrow (!) so that they are in the same order as the usual vi keys : down on the left, up on the right. I've switched the keycaps on my keyboard.

If the control key mysteriously stops working it usually means you've accidentally taken it out of Windows mode: hold down capslock and press w (the keys labelled capslock and w, not the keys which generate those characters...)

MacOS X

I have a working version of this layout for MacOS X too; I may write the details up at some point...


This page written by Peter Maydell (pmaydell@chiark.greenend.org.uk).