I have a new bluetooth keyboard, and for some reason the keycode that the escape key returns is 172 instead of 1 (according to 'showkey'; the same codes have 8 added in xkb, so 180 instead of 9). By following this answer I am able to remap ESC to work on keycode 180 instead of 9, so that's great, however I cannot seem to do it twice, i.e. write

    <ESC> = 9;
    <ESC> = 180;

In this case only the latter setting works. This is sub-optimal because it then breaks the key on the in-built keyboard. So I can get one or the other to work fine, but not both.

What is the correct thing to do about this?

2 Answers 2


As I understand it, you have to go through two levels of mapping. In the keycodes mapping you give "arbitrary" names (up to 4 chars inside <>) to the numeric scan-codes generated by the keyboard, then in the symbols mapping you say how that key name acts. So you need to have

<ESC> = 9;
<ESC2> = 180;

then an xkb_symbols entry of

 key <ESC2>  {  [ Escape        ]   };

However, in your case of 2 keyboards, you should really simply set up a different layout for each keyboard instead of making a compatible one. Use xinput -list to get the ids of your keyboards, and for each run setxkbmap -device id ... and the other arguments specifying model, layout, variant, and option for that specific keyboard.


According to An Unreliable Guide to XKB Configuration, you can do this with an alias. That feature is used in xkb/aliases, so you should be able to do something like

alias <ESC> = 9;
alias <ESC> = 180;
  • 1
    Arg, well maybe, but that exact thing is bad! It crashed my system and made booting both normally and via recovery mode impossible. I think it was causing a segfault in some xkb library. Had to boot into a rescue console via my install disk and change it back, then got back to my original (much more minor :p) problem. Phew.
    – Ben Farmer
    Apr 29, 2016 at 15:14
  • Also I don't think aliases work like that, seems more like they are designed to assign e.g. <ESC> to another symbolic name, not to multiple keycodes.
    – Ben Farmer
    Apr 29, 2016 at 15:17

You must log in to answer this question.

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