Below is the XKB file that I use on my keyboard in order to type German characters. The Right-Alt key is overridden and used for typing the characters. RAlt-a produces ä, RAlt-e produces €, RAlt-s produces ß, RAlt-u produces ü, RAlt-o produces ö.

Most of the other keys are also used to print extended characters.. you'll just have to experiment, as they're defined in the latin keymap.

However, we override a few keys here to make dead keys, which allow things like accents. RAlt-' then "a" by itself produces "á", RAlt-` then "a" produces "à". You can probably figure out what does what by reading the mappings below directly.

I load this with <kbd>setxkbmap us_de</kbd>, but you could also add an entry in /etc/X11/xkb/rules/xorg.xml (or xfree86.xml) and then select it from the GNOME keyboard configurator.

// This file is located at /etc/X11/xkb/symbols/pc/us_de
//
// It works on RHEL4.. Ubuntu requires that you place it in symbols/ and
// change the include path below.

partial default alphanumeric_keys
xkb_symbols "basic" {

    include "pc/latin"
    name[Group1]="en_US";
    name[Group2]="de_DE";

    key  { [   2, at,  twosuperior, oneeighth ] };
    key  { [   3,  numbersign, threesuperior,  sterling ] };
    key  { [   4,   dollar,   onequarter,  currency ] };
    key  { [   e,        E,   EuroSign,    EuroSign ] };
// ydiaeresis is for .nl
    key  { [   y, Y, ydiaeresis, yen ] };
    key  { [   u, U, udiaeresis, Udiaeresis ] };
    key  { [   o, O, odiaeresis, Odiaeresis ] };
    key  { [   a, A, adiaeresis, Adiaeresis ] };
    key  { [   s, S, ssharp ] };
    key  { [   slash,   question,  questiondown,  dead_hook ] };
    key  { [   apostrophe, quotedbl, dead_acute, dead_diaeresis ] };
    key  { [   1, exclam, exclamdown, exclamdown ] };
    key  { [   n, N, ntilde, Ntilde ] };
    key  { [   slash, question, questiondown, questiondown ] };
    key  { [   grave, asciitilde, dead_grave, dead_tilde ] };
    key  { [   0, parenright, dead_abovering ] };
    key  { [   minus, underscore, dead_macron ] };
    key  { [   comma, less, dead_cedilla, dead_ogonek ] };
    key  { [   6, asciicircum, dead_circumflex, dead_caron ] };
    key  { [   9, parenleft, dead_breve ] };
    key  { [   0, parenright ] };
    key  { [   equal, plus, dead_doubleacute ] };

    include "level3(ralt_switch_multikey)"
};

If you're not in a position to modify the system files, you can also use an xmodmap file, such as the following:

keycode 0x1A =  e               E               EuroSign        currency
keycode 0x1E =  u               U               udiaeresis      Udiaeresis
keycode 0x20 =  o               O               odiaeresis      Odiaeresis
keycode 0x26 =  a               A               adiaeresis      Adiaeresis
keycode 0x27 =  s               S               ssharp          section
! right alt
keycode 0x71 =  Mode_switch

Save that as .xmodmap (or whatever), and load it with <tt>xmodmap .xmodmap</tt>

— by Robert Thomson, created 3rd Jan, 2007, last modified 10th Apr, 2010 | Tags: Tech