1 TITLE: Spanish characters on a US International keyboard
3 LFS VERSION: 3.1 (should apply to all)
5 AUTHOR: David Ayers <fogey@mindspring.com>
9 My default keyboard is US International. I want to be able to write
10 Spanish text, using a keyboard modifier key (like Alt, Ctrl, etc) to,
11 for example, cause the "a" to become "á" (accent) by using the a key
12 in combination with a modifier key. This hint describes how I remapped
13 my Microsoft keyboard to use the Menu key as the modifier key. The
14 same general procedure should apply to any keyboard and any desired
15 mapping. Pressing the Menu Key in combination with certain letter or
16 symbol keys yields: á Á é É í Í ó Ó ú ü ñ Ñ ¡ ¿.
23 Revision 1.1 2002/06/25 dca
24 Miscellaneous wording and format changes.
29 Linux Keyboard and Console How-To (essential)
31 X Window System User's Guide, Volume Three, Part Two, Chapter 14,
32 "Modifier Key and Pointer Customization: xmodmap
39 LFS Version CVS-20020131
43 XF86Config (keyboard-pertinent portions):
45 Section "ServerLayout"
46 Identifier "XFree86 Configured"
48 InputDevice "Mouse0" "CorePointer"
49 InputDevice "Keyboard0" "CoreKeyboard"
53 Identifier "Keyboard0"
57 (Earlier versions of X may have Section "Keyboard" instead of Section
63 The Linux keyboard and console is handled one way but X substitutes
64 its own handling. This hint considers only the X keyboard mapping.
66 The XFree86 keymap mechanism is much more limited than the Linux
67 mechanism. Since version 2.1, XFree86 will initialize its keymap from
68 the Linux keymap as far as possible. However, Linux presently has 256
69 possible entries per key, while X has only 4 entries per key (one for
70 each combination of Shift, Mod), so some information is necessarily
73 First, X reads the XF86Config file, where definitions of LeftAlt,
74 RightAlt, etc. might be found. - see XFree86kbd(1). In my system there
75 are no key definitions in the config file. Next, the kernel keymap
76 is read and the usually obvious keybindings are made. The X keymap
77 duplicates the kernel keymap as closely as it can.
79 Xmodmap is your friend
80 ----------------------
82 Save your current X keymap.
84 $ xmodmap -pke > keytable
86 This will tell you how your keyboard is presently mapped. You can
87 easily correlate the listed keycodes with the keys on your keyboard by
88 looking at what the key does. For example, in my keytable I find lines
95 keycode 12 = 3 numbersign
98 The above tells me that pressing the unshifted 1 key produces the
99 numeral 1, and <shift>-1 produces the exclamation mark.
101 To see the current the modifier keys assignment
105 which displays something like
107 xmodmap: up to 2 keys per modifier, (keycodes in parentheses):
109 shift Shift_L (0x32), Shift_R (0x3e)
110 lock Caps_Lock (0x42)
111 control Control_L (0x25), Control_R (0x6d)
112 mod1 Alt_L (0x40), Alt_R (0x71)
118 This says that both left and right shift keys produce the shift
119 function, etc., and the Alt keys produce the mod function.
124 In the keymap, each physical key is associated with a keycode and with
125 one or more keysyms that describe what you get when you press the
126 key. Some obvious keysyms are 1, 2, 3, a, b, c, etc. Also, exclam, at,
127 and numbersign are keysyms for the characters !, @, and #.
129 To discover which additional keysyms are available for use beyond the
130 ones used in the current keymap,
132 $ less /usr/X11R6/include/X11/keysymdef.h
134 Look in the "Latin 1" section of keysymdef.h to see lines like
136 #define XK_exclamdown 0x0a1
138 The keysym name is "exclamdown". Its function is to print the
139 upside-down exclamation mark that is one of the Spanish symbols
140 needed. I decided to add these keysyms to my keyboard:
151 The /etc/keys.es file
152 ---------------------
154 Create a file containing the keycodes that are to be remapped. The
155 file can have any name and be located anywhere. Mine is named
156 /etc/keyes.es, mod 644 and owned by the user.
158 My keys.es file looks like this:
160 keycode 117 = Mode_switch
161 keycode 38 = a A aacute Aacute
162 keycode 26 = e E eacute Eacute
163 keycode 31 = i I iacute Iacute
164 keycode 32 = o O oacute Oacute
165 keycode 30 = u U uacute udiaeresis
166 keycode 57 = n N ntilde Ntilde
167 keycode 61 = slash question slash questiondown
168 keycode 10 = 1 exclam 1 exclamdown
170 The first line, keycode 117, assigns my "Menu" key to be the mod
171 key. For non-Microsoft keyboards, any unused key or perhaps one of the
172 Alt keys might be used as the mod key. You can get the appropriate
173 keycodes from your saved keytable file.
175 The remaining lines each have four keysyms listed, corresponding to
176 unshifted, shifted, mod-unshifted, and mod-shifted.
183 $ xmodmap /etc/keys.es
189 to see that the new keysyms were added to the keymap. If it looks
190 good, add 'xmodmap /etc/keys.es' as the next-to-last command in your X
191 startup script. I use startx to run X and XFce from the command line,
192 so the xmodmap command goes in ~/.xinitrc. The last two commands in my
195 # Modify keyboard mapping to add Spanish special characters
196 /usr/X11R6/bin/xmodmap /etc/keys.es
198 # Finally, launch XFce window manager
204 When I remapped my X keyboard, the keymapping worked as expected in
205 all of my editors and wp applications. The same keymapping would also
206 be desirable for non-X apps like emacs and vim. It should be a simple
207 matter of editing the Linux keymap. I haven't done this yet. Perhaps