British English on a US Keyboard

 

I keep reading “reviews” on Ebay and Amazon UK that British people are buying keyboards on line, only to find that they are American. The main problem they have is that the keyboard does not have a Sterling sign (£) on it, the quotedbl (“) and at sign (@) are swapped over. The key that produces hash and tilde has backslash and pipe on it, backslash and pipe are no longer available, as there is one key less on the US keyboard! Everything will appear in the same place on the keyboard as they did before, but the legends on the keys are wrong.

If you switch to the US keyboard layout, everything will match up to what is on the keyboard, but you won’t have access to a £-sign. So what to do?

keyboard

There is a directory, /usr/share/X11/xkb/symbols/, that holds many keyboard maps, and the British one is “gb”. If you look at it, you will see a number of sections, the first one is “default”, and looks like this:

// based on a keyboard map from an 'xkb/symbols/gb' file

default  partial alphanumeric_keys
xkb_symbols "basic" {

    // Describes the differences between a very simple en_US
    // keyboard and a very simple U.K. keyboard layout defined by
    // the SVR4 European Language Supplement and sometimes also
    // known as the IBM 166 layout.

    include "latin"

    name[Group1]="English (UK)";

    key <AE02>	{ [         2,   quotedbl,  twosuperior,    oneeighth ]	};
    key <AE03>	{ [         3,   sterling, threesuperior,    sterling ]	};
    key <AE04>	{ [         4,     dollar,     EuroSign,   onequarter ]	};

    key <AC11>	{ [apostrophe,         at, dead_circumflex, dead_caron]	};
    key <TLDE>	{ [     grave,    notsign,          bar,          bar ]	};

    key <BKSL>	{ [numbersign, asciitilde,   dead_grave,   dead_breve ]	};
    key <LTGT>	{ [ backslash,        bar,          bar,    brokenbar ]	};

    include "level3(ralt_switch_multikey)"
};

Let me explain a few lines. The one that says include “latin”, means that stuff is read in from another file, called… “latin”, in the same folder. That’s a generic European key layout, which is basically the same as the American layout but with four symbols shown on many keys instead of two. You might want to look at that file too.

Another very important line is include “level3(ralt_switch_multikey)”. This enables the Right-Alt (Alt-Gr) key to act as a shift to the third entry for each key, and together with Shift, to access the fourth entry. So, we can fix the key moves by deleting some of them. If we delete the entry for the “2” key, it will restore the “latin” definition and put back the “@” sign. Deleting the keys <AC11>, <TLDE> and <BKSL>, will also put those keys back to the symbols on the keys. The key <LSGT> isn’t present on a US keyboard so we can delete that too. The “4” key is left alone, so it will produce both “$” and “€”. That leaves the “3” key. We need the “£” on that which we can access through Alt-Gr. Best is to swap the third and fourth positions on that key.

So your new layout will look like this:


// based on a keyboard map from an 'xkb/symbols/gb' file
// edited for UK on a US keyboard

default  partial alphanumeric_keys
xkb_symbols "basic" {

    // Describes the differences between a very simple en_US
    // keyboard and a very simple U.K. keyboard layout defined by
    // the SVR4 European Language Supplement and sometimes also
    // known as the IBM 166 layout.

    include "latin"

    name[Group1]="English (UK)";

    key <AE03	{ [         3,   numbersign, sterling, threesuperior ] };
    key <AE04	{ [         4,     dollar,     EuroSign,   onequarter ]	};

    include "level3(ralt_switch_multikey)"
};

Don’t edit the file in place, copy it somewhere else and edit it, and also keep a copy of the original to put back in case of error. When you re-install, or sometimes after an update, you will need to copy the file back over the top of the “official” one.

Going through the “latin” file, you might not be happy with many of the defaults. For example, Alt-Gr and q makes an @-sign, which is already on the keyboard. So you might want to put in a line as follows:


key <AD01>	{ [         q,          Q,           infinity,  Greek_OMEGA ]	};

NOTE: Do not edit the “latin” file, this goes in the gb file. The less files edited the better! Of course there is nothing to stop you copying a line from the “latin” file, pasting it into the gb file, then editing it. This will produce the infinity sign “∞” on Alt-Gr q. You don’t need to know the name of the key you want to substitute, you can use the Unicode number (if 4 hex numbers) U221E, or for Unicode numbers above FFFF, you can use 0x1 followed by the 6-hex figure code, so, the infinity sign would be 0x100221E. You can redefine the third and fourth level keypresses for a number of keys if you wish. I have!

Just remember to keep the original just in case, and to back up the edited version so that you can restore it should the system over-write it on an update.

If you’re like me, you will have the CAPS LOCK key defined as the compose key, for 2 reasons. One is to get a compose key, and the other is to prevent you putting on CAPS LOCK in error. You can do this from the Control Centre in KDE, but with other desktops you can’t. To put it right in the “gb” keyboard definition file, just add this line:


key <CAPS> { [ Multi_key ] };

On some of these keyboards,  after the F10 key, there are F11 and F12, but on the one I got, there’s not. There is a redundant NumLock key and a rather useless Pause/Break key. In the BIOS, I turned off startup numlock. Then into the Settings Manager, I ensure that any NumLock background service was disabled. Finally, in my desktop settings, I ensured that NumLock is turned off at startup.

Now set your keys in the “gb” file we discussed before:


    key <NMLK>  { [  F11  ] };
    key <PAUS>  { [  F12  ] };

Overall, the main section of the “gb” file will now look like this:


// based on a keyboard map from an 'xkb/symbols/gb' file
// edited for UK on a US keyboard

default  partial alphanumeric_keys
xkb_symbols "basic" {

    // Describes the differences between a very simple en_US
    // keyboard and a very simple U.K. keyboard layout defined by
    // the SVR4 European Language Supplement and sometimes also
    // known as the IBM 166 layout.

    include "latin"

    name[Group1]="English (UK)";

    key <CAPS> { [ Multi_key ] };
    key <NMLK>  { [  F11  ] };
    key <PAUS>  { [  F12  ] };
    key <AE03>	{ [         3,   numbersign, sterling, threesuperior ] };
    key <AE04>	{ [         4,     dollar,     EuroSign,   onequarter ]	};
    key <AD01>	{ [         q,          Q,     infinity,  Greek_OMEGA ] };

    include "level3(ralt_switch_multikey)"
};

And that, folks, is how Linux enables you to control your machine and not the other way around!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: