Typo
[linux_from_scratch_hints.git] / OLD / keyboard_us2es.txt
blob39d2000df76bd8b504a536253ba9facf0a4b411e
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>
7 SYNOPSIS:
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: á Á é É í Í ó Ó ú ü ñ Ñ ¡ ¿.
18 HINT:
20 Changelog
21 ---------
23 Revision 1.1 2002/06/25 dca
24 Miscellaneous wording and format changes.
26 Information sources
27 -------------------
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
34    xmodmap(1)
36 My LFS system
37 -------------
39    LFS Version CVS-20020131
40    Linux 2.4.17 
41    XFree86 4.2
42    XFce desktop
43    XF86Config (keyboard-pertinent portions):
45    Section "ServerLayout"         
46         Identifier     "XFree86 Configured"         
47         Screen         "Screen0" 0 0         
48         InputDevice    "Mouse0" "CorePointer"         
49         InputDevice    "Keyboard0" "CoreKeyboard" 
50    EndSection
52    Section "InputDevice"
53         Identifier  "Keyboard0"
54         Driver      "keyboard"
55    EndSection
57 (Earlier versions of X may have Section "Keyboard" instead of Section
58 "InputDevice")
60 The X keyboard 
61 -------------- 
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
71 lost .
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
89 like
91    keycode   8 =
92    keycode   9 = Escape
93    keycode  10 = 1 exclam
94    keycode  11 = 2 at
95    keycode  12 = 3 numbersign 
96    ...
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
103    $ xmodmap
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)
113    mod2 
114    mod3
115    mod4 
116    mod5
118 This says that both left and right shift keys produce the shift
119 function, etc., and the Alt keys produce the mod function. 
121 Keysyms
122 -------
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:
142    aacute, Aacute
143    eacute, Eacute
144    iacute, Iacute
145    oacute, Oacute
146    uacute, udiaeresis
147    ntilde, Ntilde
148    questiondown
149    exclamdown 
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.
178 Final configuration
179 -------------------
181 Try it out. run
183    $ xmodmap /etc/keys.es
185 then
187    $ xmodmap -pke 
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
193 .xinitrc are:
195    # Modify keyboard mapping to add Spanish special characters
196    /usr/X11R6/bin/xmodmap /etc/keys.es
198    # Finally, launch XFce window manager
199    exec xfwm.
201 The console
202 -----------
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
208 Real Soon Now.
224    
232