# X11 Keyboard



## hruodr (Sep 1, 2017)

Perhaps here is an X11 expert that helps me save time. 

An Introduction of how X11 treats the keyboard is here: https://www.jwz.org/xkeycaps/man.html

Also the manpages xmodmap() and xev() help.

I have an old Compaq german keyboard.

Q1. Can I expect that the correspondence of KeyCaps (letters printed on keys) and KeyCodes (fixed codes of keys to treat them by X11) coincide in similar (german) keyboards?

I have X11 as in my installation. Here are the modifiers set in my system:


```
# xmodmap
xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x6d)
mod1        Alt_L (0x40),  Meta_L (0x9c)
mod2        Num_Lock (0x4d)
mod3  
mod4        Super_L (0x73),  Super_R (0x74),  Super_L (0x7f),  Hyper_L (0x80)
mod5        Mode_switch (0x8),  ISO_Level3_Shift (0x7c)
```

According to `xev`, Shift_L (0x32),  Shift_R (0x3e), Caps_Lock (0x42), Control_L (0x25),  Control_R (0x6d), Alt_L (0x40), Num_Lock (0x4d) are the expected keys; Super_R (0x74) and  Super_L (0x7f) are the Windows keys.

Well, with `xev` I do not find Meta_L (0x9c), Super_L (0x7f), Hyper_L (0x80), Mode_switch (0x8) and ISO_Level3_Shift (0x7c). And sure it is expected, that not all KeyCodes should be generated by my keyboard.

According to `xev`, ISO_Level3_Shift is bound to keycode 113 (0x71), the key bottom left with KeyCap "Alt Gr". This is not a modifier, not the above mod5. But "Alt Gr", as "Alt", does behave as a modifier. Why?!

I press them in and xterm together with an alphanumeric key and I get a modified character. Why?

Q2. Why Alt and AltGr behave like that?

Here an excerp of my keymap table:


```
# xmodmap -pke
keycode   8 = Mode_switch NoSymbol Mode_switch
keycode   9 = Escape NoSymbol Escape
keycode  10 = 1 exclam 1 exclam onesuperior exclamdown onesuperior
keycode  11 = 2 quotedbl 2 quotedbl twosuperior oneeighth twosuperior
[...]
keycode  24 = q Q q Q at Greek_OMEGA at
[...]
keycode  63 = KP_Multiply KP_Multiply KP_Multiply KP_Multiply KP_Multiply KP_Multiply XF86ClearGrab
[...]
keycode  95 = F11 F11 F11 F11 F11 F11 XF86Switch_VT_11
[...]
keycode 102 = Right NoSymbol Right
keycode 103 = End NoSymbol End
[...]
keycode 255 =
```

A superficial view of the table shows:

(1) There are some KeyCodes (like 255) with no KeySym assigned.

(2) Normally are assigned from 3 to 7 KeySyms to each KeyCode.

(3) the third and fourth KeySym (reachable with the non existent Mode_switch and Shift Mode_switch are identical wth the first and seccond KeySym (Key without modifier and Key with Shift).

(4) Normally, the 7th (last) KeySym coincides with the 5th. When not, there are these strange XF86* KeySyms.

This happens with KeyCode 24:

Without Modifier: q
With Shift: Q
With "Alt Gr": @ (5th KeySym in keymap)
With Shift AltGr: Ω (6th KeySym in keymap)
With Alt: ñ in xterm, but nothing in firefox..
With Shift Alt: Ñ, but nothing in firefox.

Q3. From where get xterm the mapping?

Q4. Why does Alt Gr behaves as such modifier? Does it take always 5th and 6th KeySym from the keymap?


----------

