Chapter 19. Keyboard

The keyboard is one of the two chief conduits of communication from the user to your application. (The mouse is the other; see Chapter 20.) This chapter summarizes the ways in which keyboard communication can take place. Some of these ways have already been mentioned, though certain details have been postponed until now; others are described here for the first time.

A little terminology is in order at the outset. The Command key, Option key, Shift key, and Ctrl key are modifier keys. Other keys are, for lack of a better term, nonmodifier keys. Only the nonmodifier keys count as first-class citizens, in the sense that pressing one generates a keydown event at system level; the modifier keys are merely ancillary, their purpose being to alter the meaning of the nonmodifier keys.[115]

On Windows, what REALbasic calls the Option key maps to the Alt key, and what REALbasic calls the Command key maps to the Windows key.

Keyboard Communication

Here are all the ways in which your application might learn that the user has pressed a key:

  • The user presses a nonmodifier key and is holding down the Command key. This causes a menu-enabling moment, during which the keypress can be detected, if desired, in any of the resulting EnableMenu or EnableMenuItems events, through the Keyboard object, as explained later in this chapter. If the keypress matches the keyboard equivalent of a menu item that is enabled when the menu-enabling moment is over, a menu event will be generated ...

Get REALBasic: TDG, 2nd 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.