I have a US keyboard by I'm using a British keyboard layout.

The US keyboard doesn't physically have the keys \ (backslash) and | (vertical bar).

I'd like to remap them to Alt # and Alt ~ respectively.

How can I achieve this?

I'm running Ubuntu Artful, which uses xkb.

1 Answer 1


It's not crystal clear what you mean, but possibly you want to edit the /usr/share/X11/xkb/symbols/gb file and change the line

key <BKSL>  { [numbersign, asciitilde,   dead_grave,   dead_breve ] };


key <BKSL>  { [numbersign, asciitilde,    backslash,          bar ] };


Right Alt + # => \

Right Alt + Shift + # => |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.