Can someone help me on this problem? I have keyboard that does not have a key to write the | and \. I would like to map some key stroke combination (hopefully a simple one, like AltGr + P). Is that possible?

I tried to follow some instructions of xkb, but I could not do it, unfortunately. I am using the Cinnamon Desktop environment.

  • 1
    what's your 0S??
    – PRATAP
    Nov 22, 2019 at 12:43
  • Ubuntu 18.04. This is a samsung S51Pro laptop with a "sort off" brazilian keyboard (sort off because the brazilian keyboard has a key for these characters just besides the "Z" letter, but this keyboard does not have it).
    – leandro
    Nov 22, 2019 at 13:09

2 Answers 2


A rather simple way to be able to type these characters conveniently using a keyboard combination could be to use xdotool. Among other things, xdotool can simulate typing.

In principle, the command

xdotool type '|'

will type the | character. Bind that command to a hotkey using your window manager (in standard Ubuntu: "Settings - Keyboard Shortcuts").

In practice, when you hold down your hotkey, the system will not see the action of xdotool as a single keystroke. The most reliable way to cope with this side effect is to have xdotool simulate that you are releasing your shortcut keys before it types the character.

Supose we want to bind Alt_R+p. xev learns me that my right Alt key is identified as ISO_Level3_Shift. Thus, we can make xdotool release the keyboard combination before typing the character, as in:

xdotool keyup ISO_Level3_Shift+p type '|'
  • Thank you! The only thing is that since Alt_R+p is already bound to a character, I had to change for Control_R+bracketleft Thus, I followed your steps, except that the command was: xdotool keyup Control_R+bracketleft type '|' and it was bound to the hotkey Control-[
    – leandro
    Nov 23, 2019 at 13:18
  • Perfect! I know this is just a hack, but for just a few characters a very acceptable one.
    – vanadium
    Nov 23, 2019 at 13:24

Well, to be truth, that solution didn't worked properly, because the functioning of xdotools was not very predictable.

I had then to reconfigure the keyboard. In my case, I was using the "Portuguese (Brazil)" keyboard. Therefore, I opened the


file, and changed all "EuroSign" appearances by "bar"

after logout and login, the AltGr+E combination (which resulted in an EuroSign), now results in the "|" character I wanted.

You must log in to answer this question.

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