System 7: Modifying the Keyboard Layout Switching Command

Under System 7.x, I can switch keyboard layouts by pressing the Command-Option-Space Bar keys. This feature is probably not well known in the U.S., where normally only one keyboard layout is installed. However, in most European countries you may have at least two keyboard layouts installed.

In Norway we have three: two different Norwegian (only one key is different) and the U.S. keyboard layout. The ability to change keyboard layouts in environments with employees from different countries is appreciated. And with the Keyboard menu (between the Help menu and the Application menu) enabled with a little help from ResEdit, it's very easy to find the keyboard layout in use.

Many heavy users in the graphics business have upgraded to System 7.x, or bought Macintosh Quadra systems. The keyboard layout switch shortcut causes issuess in some common graphics applications such as Adobe PhotoShop, Adobe Illustrator, and Quark XPress.

Adobe PhotoShop and Adobe Illustrator use the Command, Option, and Space Bar sequence to zoom the picture in, while Quark XPress uses this sequence to get a special space character called em-space (used a lot among professional typographers).

We've found a workaround with PhotoShop and Illustrator. If we press the Space key before the Command and Option keys, the keyboard layout won't change. The Quark XPress issue is more difficult, since the Command, Option, and Space Bar sequence displays a special character, rather than executing a command.

Do you have any solutions for this?
Note: System 7.5 comes pre-installed with many keyboard layouts. Also, if a System 7.5 Easy Install is performed, all the European keyboard layouts are installed as a default. The user can limit the keyboard layout installation to only the U.S. keyboard layout if a Custom Install is performed. For more information about workarounds and alternatives to using ResEdit see the following article: "System 7.5: Command-Option-Spacebar Application Conflict"

WARNING: The following instructions refer to using ResEdit to alter your system software. Apple Computer, Inc., is not liable for any damage done to your software through the use of ResEdit to alter the software.

The entries in the 'KSWP' system resource (ID = 0) control the switching of the keyboard layouts. Actually, the entries in the 'KSWP' resource control more than that. Inside Macintosh Volume VI fully documents this resource on pages 14-43 to 14-44, and pages 14-98 to 14-99.

The standard U.S. 'KSWP' resource looks like this:

FFFF 3101 FFFC 3109
FFFE 4601 0000 4201
0000 0000

Each long word entry controls a separate function. The first two bytes (integer) form the verb that the KeyScript procedure will act upon. The third byte is the virtual key code for the key that you must press, and the fourth byte is the modifier state that must exist when you press the key.

Table 14-3 on page 14-44 of Inside Macintosh Volume VI outlines the verbs for the KeyScript procedure.

You can find most of the virtual key codes on pages 191 and 192 of Inside Macintosh Volume V, or by using ResEdit on the 'KCHR' resource in the System file.

Note on modifier state: Option key down is equal to 8; Shift key down is equal to 2; and Command key down is equal to 1. If you press multiple
modifier keys at the same time, their values are added together for the modifier state entry.

The second entry in the standard U.S. 'KSWP' resource (FFFC 3109) is the one that causes the problems you describe. The first two bytes, $FFFC or -4, form the verb "smKeyNextKybd" which means "Switch to next keyboard in active script." The third byte, $31, is the virtual key code for space. The fourth byte is Command key down (1) plus the Option key down (8) which equals $09.

There are three ways to solve the problem. The first method is rather limiting and not very flexible. The second is the most straightforward,
and probably the best. The third is the most flexible, but the most complicated from a user's point of view.

- Delete the entry that causes the issue.
The 'KSWP' resource would then look like this:

FFFF 3101 FFFE 4601
0000 4201 0000 0000

- Change the virtual key code to something other than $31.
Changing it to $4C would allow the Command-Option-Enter key sequence to switch keyboard layouts. The 'KSWP' resource would look like this:

FFFF 3101 FFFC 4C09
FFFE 4601 0000 4201

0000 0000

- Add two new entries to the 'KSWP' resource.
One would disable switching from the current keyboard (verb "smKeyDisableKybdSwitch") and the other would enable keyboard switching (verb "smKeyEnableKybds"). Command, Option, and Enter disable switching, and Command, Option, and Return enable switching. The 'KSWP' resource would look like this:

FFFF 3101 FFFC 3109
FFFE 4601 0000 4201
FFF4 4C09 FFF9 2409
0000 0000

Note: The four bytes of zeroes at the end of the resource are filler and must be present.
Published Date: Feb 18, 2012