The Keyboard
The Macintosh keyboard routines handle the keyboard properly for script
systems. Except for purely hardware-specific characteristics, the function of
the keyboard is completely determined by keyboard character tables in the
keyboard layouts. These are resources of type 'KCHR' with an optional
associated resource of type 'itlk'. Each table specifies the character produced
by each key in combination with each modifier key (Command, Shift, Caps
Lock, Control, and Option). In addition, the 'KCHR' resource also handles dead
keys by means of additional sub tables. Dead keys are the modifier-plus-key
combinations that usually produce no immediate effect but instead affect the
character or characters produced by the next key- called the completer
key-that is pressed. For example, pressing Option-E produces nothing (no
event is posted), but subsequently typing E produces é.
Note that you can edit the 'KCHR' resources by using ResEdit. For details on all
the keyboard resources, see the relevant sections under
Using the International and Keyboard Resources.
The Figure below illustrates the process of keyboard translation. Keyboards
produce raw key codes. The hardware-dependent 'KMAP' resource is then used
to map these key codes to hardware-independent virtual key codes and to set
bits indicating the state of the modifier keys. (If you do not have access to the
MPW file SysTypes.r, which contains a Rez type definition of the 'KMAP'
resource, consult Macintosh Developer Technical Support for details.)
The 'KCHR' resource specifies how to map a modifier state and a virtual key
code to a character code. It includes information on how to process dead
keys.The optional 'itlk' resource specifies how to remap certain key
combinations on certain keyboards before the 'KCHR' mapping is used.
The 'itlk' resource transforms this information based on which keyboard
is in use and reintroduces hardware dependence because certain scripts,
languages, and regions need subtle differences in layout for specific keyboards.
The 'itlk' resource generally only affects a few keys.The 'KCHR' and 'itlk'
resources are used by the KeyTrans function. Note: Do not change the 'KMAP' resource because everything you
need is in the 'KCHR' and 'itlk' resources. You only need to work with
'KMAP' if you are making your own keyboard.
Keyboard translation
The net result of the process of keyboard translation illustrated in the Figure
for details about the internal structure and the function of the 'KCHR'
resource.
The 'KSWP' resource specifies which modifier-plus-key combinations you
can use to change scripts and keyboard layouts within scripts. For example,
the standard 'KSWP' resource specifies that pressing Command-Space bar
changes the keyboard to the default keyboard for the next script. For details on
these keyboard resources and other keyboard issues, see
Using the International and Keyboard Resources and Macintosh Worldwide Development: Guide to System Software.