I am running Ubuntu server 16.04. Not sure if this matters, but I am forwarding the screen to a browser using XPRA.

All works reasonably well except for a few pesky key combinations. I am using a GB keyboard where between the SHIFT and Z keys there is a key with backslash and bar (pipe), let's call this the 'bar key'. At the top left of the keyboard there is a key with a grave and notsign, let's call this the 'grave key'.

These keys all work fine in the client OS as well as when using SSH to the server. However, the moment I use them in any of the forwarded applications, e.g. xterm, they display incorrect characters.

The 'bar key' displays '\' (correct) and '¬' (incorrect, this should be '|').

The 'grave key' displays the grave '`' (correct) and notsign '¬' (correct)

So I tried the usual xev & xmodmap combination to figure out the keycodes and map them.

When I run xev I get the following output for the 'bar key'

backslash (\): keycode 94 
bar (|): keycode 49

and the following for the 'grave key'

grave (`): keycode 49 
notsign (¬): keycode 49

Looks like there is a lot going on on keycode 49, it is mapped to multiple physical keys.

To check what position things map to, I executed the following

xmodmap -e "keycode 49 = 1 2 3 4 5 6"

when I enter the various keys I get

\ = is still \ because we didn't remap 94
| = 2
` = 1
¬ = 2 (also 2 ... brilliant)

So how can I remap this if 2 characters map to the same keycode / position combination? (I have a couple of other ones to remap, e.g the @ key outputs Q, but let's get the first one going first)

Not sure if it helps, but here is some additional diagnostic info

~$ setxkbmap -query
rules: evdev
mode: pc105
layout: gb

~$ localectl status
   System Locale: LANG=en_GB.UTF-8
                  LANGUAGE=en_GB:en
       VC Keymap: n/a
      X11 Layout: gb
       X11 Model: pc101

I have spent two days on this and am losing the will to live. I hope this makes sense.

  • You might look at articles on showkey -s to see if the key is giving different scancodes when in shift and setkeycodes for mapping scancodes to keycodes before they get to X11 through /dev/input/event* which you can see with xinput --test-xi2. – meuh Feb 6 at 20:01

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.