[Xcb] XCB keyboard input

Peter Harris pharris at opentext.com
Wed Mar 8 15:45:11 UTC 2017

On 2017-03-08 9:34 AM, Chuck Pergiel wrote:

> I've been working through the tutorial and everything was going
> swimmingly until I got to the bit about keyboard input.
> Pressing the ESC key sends a value of 9 to the program, which is great,
> but how did the ESC key get translated to 9? The section of the program
> dealing with keyboard input is listed below.

The section of the program you quoted does not translate the ESC key to
9. It relies on luck, mostly, and the fact that historically it happens
to be 9 on most x servers.

> I can enter characters at the keyboard, but the values that show up in
> the program are not the normal ASCII values. I've dug around a bit but I
> haven't found much of anything that was very helpful. 

You need to translate the keycode (plus modifiers, like shift) into a
key symbol. xcb_get_keyboard_mapping is rather sparsely documented at
. See  https://cgit.freedesktop.org/xcb/util-keysyms/ for example code.

The key symbols predate unicode (and have to encode symbols that are
outside of unicode anyway, like the F1-F12 keys on the keyboard). The
definitions are in the *keysym.h files in

You can run `xev` and press keys on your keyboard to see what is going on.

> Sent from my Commodore-64 via a US Robotics 300 Baud Modem

Luxury! I bet that even supports the standard Hayes command set. My
Commodore-64 has a no-name 300 baud modem with hardware toggle switches
on the front (no software dialing for me).

Peter Harris
               Open Text Connectivity Solutions Group
Peter Harris                    http://connectivity.opentext.com/
Research and Development        Phone: +1 905 762 6001
pharris at opentext.com            Toll Free: 1 877 359 4866

More information about the Xcb mailing list