Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Text /
Appendix C - Keyboard Resources / Key-Map Resource (Type 'KMAP')


Virtual Key Codes for Non-ADB Keyboards

The original Macintosh keyboard (for both the 128K and 512K versions) and the Macintosh Plus keyboard produce event records with raw key codes rather than virtual key codes, because there is no key-map resource for them. For domestic versions of these keyboards it is not a problem, because the raw key codes are identical to the virtual key codes expected by the U.S. keyboard-layout resource. The international version of the Macintosh Plus keyboard, however, and the ISO layout of the small Macintosh 512K keyboard, produce raw key codes that cannot be treated as virtual.

When a keypress from the international version of the Macintosh Plus keyboard occurs, the interrupt handler calls the _Key1Trans hook, which translates the raw key codes to virtual key codes before calling KeyTranslate. Thus your application normally receives the correct character codes even if an international version of the Macintosh Plus keyboard is attached. However, the raw key code is what is placed in the event record. Therefore, if you need to explicitly convert raw key codes to virtual key codes, you can use the values in Table C-7. Raw key codes are offsets into the table; the byte
at each offset represents the virtual key code for that raw key code. (The keyboard produces raw key codes up to $3F only; key codes above that value are generated by an optional keypad.)
Table C-7 Virtual key codes for the international Macintosh Plus keyboard
Raw codesVirtual codes
$00-$07$00$01$02$03$04$05$32$06
$08-$0F$07$08$2C$09$0C$0D$0E$0F
$10-$17$10$11$12$13$14$15$16$17
$18-$1F$18$19$1A$1B$1C$1D$1E$1F
$20-$27$20$21$22$23$2A$25$26$27
$28-$2F$28$29$24$2E$2F$0B$2D$2B
$30-$37$30$34$0A$33$31$35$36$37
$38-$3F$38$39$3A$3B$3C$3D$3E$3F

The domestic and ISO layouts of the small Macintosh 512K keyboard have keyboard types of 3 and 259, respectively. However, in both cases the low-memory global that specifies current keyboard type (KbdType) holds the value 3. The user indicates which keyboard is in use through a control in the Keyboard control panel that appears only on non-ADB systems. The user's selection is kept in the itlcOldKeyboard field of the system script's international configuration ('itlc') resource. You can examine that field if you need to know whether the ISO or domestic layout of the small Macintosh 512K keyboard is in use.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996