3

I am using ubuntu 15.10!

I would like to remap the additional '| \'-key right of the left shift key on my United Kingdom keyboard to the `-key.
Here is a picture of the mapping I want:

keyboard image

These are the results of pressing the key after 'xev -event keyboard': (sidenote: While my keyboard is british, I am using the American layout, therefore the "<")

KeyPress event, serial 28, synthetic NO, window 0x1e00001,
    root 0xb5, subw 0x0, time 28576713, (-521,515), root:(763,543),
    state 0x0, keycode 94 (keysym 0x3c, less), same_screen YES,
    XLookupString gives 1 bytes: (3c) "<"
    XmbLookupString gives 1 bytes: (3c) "<"
    XFilterEvent returns: False

KeyRelease event, serial 28, synthetic NO, window 0x1e00001,
    root 0xb5, subw 0x0, time 28576815, (-521,515), root:(763,543),
    state 0x0, keycode 94 (keysym 0x3c, less), same_screen YES,
    XLookupString gives 1 bytes: (3c) "<"
    XFilterEvent returns: False

Is this possible with the setxkbmap-command or some other way? I have tried to find a solution, but haven't been successful on my own.

I would highly profit of this remapping since I often use the `-key (I like vim) and never use this other additional key.

Seth
  • 58,122
vimpy
  • 33
  • 1
    Open a terminal and run xev -event keyboard and then press the key a few times. Close the little window that appears and then [edit] one of the keypress or keyrelease events into your question please. – Seth May 24 '16 at 16:46
  • Thank you for the feedback. I just inserted the keypress and keyrelease events! – vimpy May 24 '16 at 17:36

1 Answers1

3

Go to the folder /usr/share/X11/xkb/symbols/.

Edit the gb file and replace the following line:

key <LSGT>  { [ backslash,        bar,          bar,    brokenbar ] };

with:

key <LSGT>  { [ backslash,        grave,          bar,    brokenbar ]   };

Save and exit and then execute:

sudo dpkg-reconfigure xkb-data

Log out and back in and the broken bar will have remapped to the grave character (which I believe is what you're after).

If you keep with the US keyboard layout then edit the pc file instead of the gb file and amend the line at the top of the file:

key <LSGT> {    [ less, greater, bar, brokenbar ] };

with this if you want to use shift:

key <LSGT> {    [ less, grave, bar, brokenbar ] };

or this if you do not want to use shift:

key <LSGT> {    [ grave, greater, bar, brokenbar ] };

and follow the rest of the process as above. The change will be permanent so if you want to change it back you will need to reverse the change by re-editing the file back to the original.

gsxruk
  • 1,380
  • I actually do not want the broken bar to be remapped to the grave character, but only the above shown key (which is currently a "<" key, since I am using the American keyboard). But I want the other "<" and ">" keys to work normal. – vimpy May 24 '16 at 17:39
  • Apologies, I thought the question stated British keyboard. The key you show in the picture is the same key on my keyboard (except on mine the bar is shown as broken) which is a GB/UK keyboard. It worked fine when I tried it on that. – gsxruk May 24 '16 at 17:48
  • I didn't stated it very clearly I guess. It is rather complicated. My keyboard also has the key that is shown on the picture, except that the bar is shown as broken (just like yours). However, I changed the layout inside Ubuntu to the American keyboard layout. So I guess your solution won't work? (I would try it out, but I don't know how I could undo these changes in case it doesn't work properly, so I ask you first ) – vimpy May 24 '16 at 17:55
  • If you've set the layout to US the above will not work. Is there a reason you did this? Surely when you press Shift+2 you get a @ character when the key states "? Would it not be worth changing the layout back to UK if you have a UK keyboard? – gsxruk May 24 '16 at 18:24
  • I've updated the answer with the required change if you keep the US layout. That should work. However, I'd suggest you change to UK as you have a UK keyboard and follow the first one. Good luck. – gsxruk May 24 '16 at 18:50
  • I followed your second instruction (I want to keep the US layout). And it works. BUT why do I have to press shift? The whole idea is that I can reach and type the grave more easily and faster, therefore it is no improvement when I have to use shift. Is there a way to do it without having to press shift? – vimpy May 24 '16 at 19:12
  • Updated answer for you again. I believed from your picture you wanted to replace the bar. – gsxruk May 24 '16 at 19:21