Technote 1152JIS Keyboard Support in Mac OS 8By Stephen ChickBased on a DTS-J Technote by Takayuki Mizuno and Masato Nagamatsu Apple Worldwide Developer Technical Support |
CONTENTS
JIS Keyboards |
This technote describes the mechanism introduced in Mac OS 8 to support JIS (Japanese Industrial Standards) keyboards. Developers designing input methods or applications that rely on keyboard layout information should read this technote. |
The World Before Mac OS 8Japanese versions of the Mac OS contain additional resources to accommodate US and JIS keyboard layouts. Prior to Mac OS 8, this took the form of six extra keyboard-layout resources.
Table 1: Keyboard-layout resources (resource type 'KCHR' ) in Mac OS 7.xUsers were required to configure the correct keyboard-layout resource for each installed script by selecting it in the Keyboard control panel. Since only keyboard-layout resources that belong to the current script are displayed in the control panel, and a Japanese system typically contains two scripts (Japanese and Roman), at least two operations were necessary to specify the type of keyboard attached to the computer. For example, in the case of a JIS keyboard, the user would first select “Roman - JIS” in the Keyboard control panel. ![]() Figure 2: Selecting “Roman - JIS” in the Keyboard control panel Next, the user would switch the active script to Japanese (from the script menu), and select “Kana - JIS” or “Romaji -JIS” from the Keyboard control panel, depending on their preferred method of typing. ![]() Figure 3: Switching the active script to Japanese ![]() Figure 4: Selecting “Kana - JIS” in the Keyboard control panel
Selecting an incorrect keyboard type for either Japanese or Roman scripts would cause strange behavior. For example, selecting a non-JIS layout from the Keyboard control panel when a JIS keyboard was in fact connected would result in certain keys not generating Another problem prior to Mac OS 8 was the lack of a reliable method to determine whether a keyboard's layout was JIS or not. Input methods circumvented this by maintaining static tables of keyboard IDs that were known to be JIS. By comparing the As if this weren't confusing enough, most input methods bypassed the Keyboard control panel altogether and implemented their own Kana and Romaji settings. So, in fact, it didn't make a difference whether “Romaji / Romaji-JIS” or “Kana / Kana-JIS” was selected in the Keyboard control panel. |
The World After Mac OS 8To remedy the above problems, Apple made the following improvements in Mac OS 8:
The rest of this technote describes each of these improvements in detail. New Key-Remap ResourcesWhen a key is pressed, the keyboard generates a raw key code which is mapped onto a virtual key code using a key-map resource (resource type ![]() Figure 5: The general flow of a key event with intervention by a key-remap resource. What happens without the key-remap resource? When a key is pressed, the key-map resource (resource type ![]() Figure 6: Pressing “@” on a JIS keyboard with “Roman - JIS” selected. However, if the selected keyboard-layout resource is “U.S.”, ![]() Figure 7: Pressing “@” on a JIS keyboard with “U.S.” selected. In order to generate the correct character code for “@” ( ![]() Figure 8: Generating “@” on a US keyboard with “U.S.” selected. In order to generate the correct character code for “@” ( ![]() Figure 9: Generating “@” on a JIS keyboard with “U.S.” selected. In other words, it is possible to generate the correct character on a JIS keyboard with the standard “U.S.” JIS keyboards supported in Mac OS 8.5.1 As of Mac OS 8.5.1, support for the following JIS keyboards is integrated into the System file. As new keyboard IDs are issued, they will continue to be incorporated into later versions of the operating system.
Key codes affected by key-remap resources The following key codes may be altered by the key-remap resources in Mac OS 8.
KBGetLayoutTypeInput methods or applications that need to know the type of keyboard attached to the computer (JIS or non-JIS) should use the new Since the keyboard library is only present in Japanese versions of Mac OS 8.0 and above, and because of a bug in Mac OS 8.5 (see warning), it is essential to check for availability of the API first (see the following sample code): Be sure to download and link with the keyboard library.
A new Keyboard control panelThe new Keyboard control panel in Mac OS 8 does not list two-byte scripts such as Japanese in the “Script” pop-up menu. Functionality that was previously part of the Keyboard control panel has either been made obsolete or has been incorporated into input methods. ![]() Figure 10: The Keyboard control panel in Mac OS 8.5 Compatibility GotchasMost existing input methods contain keyboard-layout resources (resource type
|
Kotoeri 2.0The Japanese version of Mac OS 8.0 includes version 2.0 of Kotoeri (the standard input method that ships with Mac OS). Kotoeri 2.0 uses In principle, Kotoeri uses the character codes provided by the Text Services Manager. To change the typing method (Kana or Romaji), Kotoeri sets the active keyboard-layout resource by specifying its resource ID (
Kotoeri also supports the Caps Lock key as a means of switching the input mode. To support this feature, Kotoeri clears the Caps Lock bit in the modifier flags. It then passes the updated modifier flags and the pointer obtained from |
SummaryApplications and input methods that require keyboard layout information and will be used in Japan need to be aware of JIS keyboards. |
|
Thanks to Deborah Grits, Hidetomo Katsura, Ingrid Kelly, and Yasuo Kida.