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.

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.