The procedure for doing that as explained in this article is based on the Ubuntu 8.04 (Hardy Heron) distribution and has been tested on versions through 11.04 (Natty Narwharl). It should work in other distributions using the Gnome desktop. Otherwise, details will vary depending on the distribution you're using.
To change or add the keyboard layout in Ubuntu Linux, select Preferences from the System menu, and then select Keyboard. Select the Layouts tab to add or change the keyboard layout. For U.S. residents using English as a first language, the best choice (and the one explained here) is the USA International (with dead keys) layout.
The USA International (with dead keys) layout gives you two ways of typing Spanish letters (and the letters of some other European languages) with diacritical marks, the dead-key method and the RightAlt method.
Dead keys: The keyboard layout sets up two "dead" keys. These are keys that seem to do nothing when you press them. But what they actually do is affect the following letter you type. The two dead keys are the apostrophe/quotation key (usually to the right of the colon key) and the tilde/opening-single-quote key (usually to the left of the 1 key).
Pressing the apostrophe key will place an acute accent (like on the é) on the following letter. So to type an é with the dead-key method, press the apostrophe key and then the "e." (To make a capital accented É, press and release the apostrophe, and then press the shift key and "e" at the same time.) This works for all of the Spanish vowels (as well as some other letters used in other languages).
To type the ñ, the tilde key is used as the dead key. Press the shift and tilde keys at the same time (as if you were typing a stand-alone tilde), release them, then press the "n" key.
To type the ü, press the shift and apostrophe/quotation key at the same time (as if you were typing a double quotation mark), release them, and then press the "u" key.
One problem with the use of dead keys is that they don't work well for their original function. To type an apostrophe, for example, you have press the apostrophe key and follow that with the space bar.
RightAlt method: The USA International (with dead keys) layout gives you a second method of typing the accented letters, as well as the only method for Spanish punctuation. This method uses the RightAlt key (usually to the right of the space bar) pressed at the same time as another key.
For example, to type the é, press the RightAlt key and the "e" at the same time. If you want to capitalize it, you need to press three keys simultaneously: the RightAlt, "e" and shift keys.
Similarly, the RightAlt key can be used in conjunction with the question mark key to make the inverted question mark, and with the 1 key to make the inverted exclamation point.
Here is a summary of the Spanish characters and symbols you can make with the RightAlt key:
- á — RightAlt + a
- Á — RightAlt + Shift + a
- é — RightAlt + e
- É — RightAlt + e + Shift
- í — RightAlt + i
- Í — RightAlt + i + Shift
- ñ — RightAlt + n
- ñ — RightAlt + n + Shift
- ó — RightAlt + o
- Ó — RightAlt + o + Shift
- ú — RightAlt + u
- Ú — RightAlt + u + Shift
- ü — RightAlt + y
- Ü — RightAlt + y
- ¿ — RightAlt + ?
- ¡ — RightAlt + !
- « — RightAlt + [
- » — RightAlt + ]
Switching between keyboards: If you spend most of your time writing in English, the dead apostrophe can become annoying after a while because it makes typing apostrophes cumbersome. One solution is to install two keyboard layouts using the Keyboard configuration tool described above. To easily switch between layouts, install the Keyboard Indicator in one of your panels. Right-click on a panel, select Add to Panel and then select Keyboard Indicator. Once it's installed, you can click on it anytime to switch layouts.
Using the Character Map: The Character Map provides a graphical display of all the characters available and can be used to select characters one-by-one for insertion in your document. In Ubuntu Linux, the Character Map is available by selecting the Applications menu, then the Accessories menu. The Spanish letters and punctuation can be found in the Latin-1 Supplement listing. To insert a character in your document, double-click on it, then click Copy. Then you can paste it in your document in the normal way, depending on your application.