I have a US keyboard, and mostly type in English. However I also want to use it occasionally for typing Portuguese; I don't want to use the GUI character map.

How can I set up the keyboard and what packages should I install so that key combinations like á = RightAlt + a will work?

I believe there is also a way to use tilde, apostrophe, and the quote key followed by a letter to achieve it, but of course it does not work by default, otherwise typing apostrophe would be difficult. However there must be a way to temporarily change something to use the keys that way.

I will mainly type in emacs, so if there is an emacs specific solution, that will also work.

  • I tried lxkeymap from the main menu, and set US International (with dead keys), and it gives me some accents (e.g., typing tilde once followed by a gives me ã, typing tilde twice gives me tilde, etc). But there are some problems. In /usr/share/X11/xkb/symbols/us there is a section us(international). I don't see how to type the characters listed in the third and the forth columns. I believe there is a compose-key and I have to type, e.g., compose-key + shift + AC11 to get double quote. But I don't know what the compose-key is.
    – sanjshakun
    Sep 9, 2011 at 10:27

2 Answers 2


I used Lxkeymap, set it in United States (my Lubuntu is in spanish so it is Estados Unidos), then selected English International (with dead keys Alt Gr) and it works fine in vim, and as you said, á = RightAlt + a.

I hope it works for emacs


You can enable the compose key by putting this in your ~/.Xkbmap file:

us -option compose:ralt

Here, ralt means right alt. For the full list of compose key combos, see /usr/share/X11/locale/$LANG/Compose . For more details, see man 7 xkeyboard-config

Unfortunately, it doesn't stick (e.g. stops working if you suspend and resume), so you may have to set it manually from time to time:

setxkbmap `cat ~/.Xkbmap`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.