Chapter 9. The Keyboard and Pointer
This chapter not only describes how to handle keyboard and pointer events but also describes many other topics related to these two input devices. In particular, it discusses X’s use of keysyms as portable symbols for character encoding, keyboard remapping, keyboard and pointer “grabs,” and keyboard and pointer preferences. Internationalized keyboard input is described in Chapter 11.
In Chapter 3, we showed you quite
thoroughly how to deal with Expose events. But all we
did with pointer and keyboard events was to exit the program. As you can
guess, there can be more to it than that. This chapter describes and
demonstrates the handling of keyboard and pointer events, describes
keyboard and pointer mapping, and describes how to set keyboard
preferences. Internationalized keyboard input is described in Chapter 11, although it depends on many
concepts described in this chapter.
9.1 The Keyboard
The keyboard is an area like color, where X clients have to be
made portable across systems with different physical characteristics. In
the case of the keyboard, these variations are in two areas: whether the
keyboard provides KeyPress and
KeyRelease events or just KeyPress
events, and the symbols on the caps of the keys.
Almost all serious workstations provide both
KeyPress and KeyRelease events.
Some personal computers, however, may not. Therefore, avoid depending on
KeyRelease events if you want your client to be
portable to the lowest classes of machines.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access