I have a ThinkPad W540. On its keyboard there are four multimedia keys above the numpad. Two of those keys generate keycodes (and, apparently, scancodes) that correspond to combination of keys, Win_L + L and Win_L + E. In other words, for the key that generates Win_L + L,
showkey --scancodes returns this:

0xe0 0x5b 0x26 0xa6 0xe0 0xdb

The setkeycodes command requires either single byte unescaped or escaped two-byte sequences to denote scan codes, and showkey gives me way more than that, so I can't quite re-map that key to one of the free keycodes in my system with a straightforward setkeycodes <scancode> <keycode>.

I would really appreciate any hints how I can remap that key to something else that doesn't simply duplicate one of the existing key combinations on my keyboard.

  • 1
    You might want to have a look at this: Shortcut keys that are independent to keyboard layout
    – terdon
    Commented Feb 6, 2014 at 21:04
  • 1
    I think this may be tricky: at least on older Thinkpads, this sort of mapping is done by the on-board controller, not the OS.
    – mirabilos
    Commented Feb 27, 2014 at 21:34
  • 1
    I have a Microsoft All-in-One Media Keyboard which has the same problem, were you able to find a solution?
    – osolmaz
    Commented Apr 20, 2015 at 22:35
  • 5
    I did something similar on a Thinkpad t61 a while ago by mapping the keys using /etc/acpi/events which is in the acpid package and just defining an action when those function keys were pressed.
    – cesar
    Commented Jan 15, 2016 at 20:29
  • 2
    Do you have Win_L setup as a modifier in X-windows? It's default for me.
    – mcr
    Commented Jul 12, 2016 at 15:01

2 Answers 2


You can do this in two steps:

  1. to catch key combinations
  2. to simulate typing different keys.

You can use xchainkeys for 1. and [xdotool][2] for 2.:

To create the simulated new key with xdotool, the option --clearmodifiers of key may be important to neutralize the original simulated modifier press:

xdotool key --clearmodifiers Shift+a

This should type a capital A as a test.

In the configuration of xchainkeys in ~/.config/xchainkeys/xchainkeys.conf, we can bind the command to a key combination:

W-l :exec xdotool key --clearmodifiers Shift+a

Now, the key combination Win and l (Win left or right do the same), as well as the key that generates Win_L + L, should create a capital A.

(There are many other programs available for both parts. For the first, one could use the hotkey configuration of a desktop environment, but I prefer to keep it independent of DEs.)

  • 2
    The problem with this solution, if I'm not mistaken, would be the same as simply using said key combination to trigger an action - that action wouldn't be triggered by just that key, pressing the actual combination of keys that generates the same codes would also give the same result. In other words, it doesn't satisfy the "remap that key to something else that doesn't simply duplicate one of the existing key combinations" condition. But I appreciate the effort.
    – moonwalker
    Commented Aug 23, 2016 at 20:31
  • 3
    Yes, that it true - I was not sure what you meant by that sentence, now I understand. But it looks like your key produces the two key codes in hardware (that is, in the keyboards firmware) - so I see no war around, except you detect the timing of the artifivial key presses "modifier down", "other key", "modifier up". Hmm... maybe a solution involving soldering is more simple ;) Commented Aug 26, 2016 at 14:13
  • 1
    @moonwalker Can you try to remap Win_L instead of the other key, and check whether it remaps the other one's modifier too? Commented Aug 26, 2016 at 14:18
  • 1
    um, wouldn't I be losing combinations like Win_L+R, Win+Break, Win+L, Win+etc. in that case?
    – moonwalker
    Commented Sep 29, 2016 at 2:57
  • 1
    No, I don't think so. Win-L is Win-Shift-l But you could also map chains of key combinations to a command. Like Win-a and after that b. With out the Win-a, b behaves normal. That's by far the most useful feature of xchainkeys, and pretty unique, I think. Commented Oct 1, 2016 at 12:19

This is what I did on my Thinkpad Yoga in order to rebind the backslash/pipe key to the correct key. Because for some reason in every Linux Virtual Machine it interpreted the backslash\pipe (\|) key as the less than (<) key.

First execute the command: xev

Press the desired key to get the keycode for the key you want to rebind:

xev KeyPress event output

In this example the Keycode is 94 and the action is "less" but we want it to have the action of backslash and bar aka "pipe"

Remap the keycode 94 to the backslash and bar key aka "pipe":

xmodmap -e 'keycode 94 = backslash bar'

Now lets make this persistent:

xmodmap -pke | egrep "backslash|bar" | grep 94 > ~/.Xmodmap`

Returns the following to the file ~/.Xmodmap:

keycode  94 = backslash bar backslash bar

Then you must create the following file to finish making it persistent:

echo "xmodmap .Xmodmap" > ~/.xinitrc
  • 2
    Backslash/pipe key generates a single scan code, the topic is about remapping keys that generate multiple scan codes.
    – moonwalker
    Commented Aug 12, 2017 at 2:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .