How can I get more control over the keyboard layout than XKB offers?

Solution 1:

Employ an extensible input method framework such as scim or ibus. The last one is possible out of the box by configuring the m17n backend, but I suspect the first two require you to program your input method.