How to Remap PowerBook Keyboard Greetings Sick of having to change your typing habits every time you move between your desk machine (Apple Standard Keyboard) and your PowerBook. Well have I got a solution for you! The following document describes how you can swap Escape with Backquote and Slosh with Enter in both hardware and software on your PowerBook keyboard. This is version 4 of my document. The previous versions were mailed out to individuals. I'm now sufficiently confident in my instructions to post it to the net (and make a *big* fool of myself). The instructions herein are not for the faint hearted. RedEditting skills are a must. Be stout of heart and do the work. I, for one, have not regretted it. Still no news on how to swap Caps Lock and Control. Sorry. Anyone with any comments should mail me at the address in my signature. Share and Enjoy. Quinn "The Eskimo!" "Real Coke, Diet .sig" Department of Computer Science, The University of Western Australia ---------------------------------------------------------------------------- Remapping PowerBook Keyboards in Hardware and Software ------------------------------------------------------ by Quinn "The Eskimo" 10 Feb 1992 0. Introduction --------------- For full enjoyment of your new PowerBook you will want to swap backquote/escape and slosh/enter. You should do this both in software and hardware. The following instructions give you information about how to do this. There is also a short spiel on why it's not possible (at the moment) to swap control and capslock. 0.1 Version History ------------------- Version 4 Changes since Version 3. o added definite information on the PB140/170 in Section 1.1 o deleted the waffle saying that I wasn't sure about the PB140/170 Changes since Version 2. o added the Creeping Legalitis section. Changes since Version 1. o added version numbering scheme o added section numbering scheme o added more warnings changing the KMAP in PowerBook 140/170s o added a discussion of the KCAP resource and instructions on how to bash it o changed the wording in the section on Hardware Remapping 0.2 Disclaimer -------------- All of this work was tested on a Australian PB100 2/20 and an Australian PB170 4/40 running System Z-7.0.1* (Australian). Your mileage may vary. Please read the Creeping Legalitis section at the end of this document. 1. Software Remapping --------------------- Warning: All the usual ResEdit warnings apply. Please make a copy of your System file before attempting this procedure. 1.1 Changing the Key Mappings ----------------------------- a) Open the System file in ResEdit. b) Open the resource KMAP ID=0 (not KCHR). c) Change the byte at offset $36 from a $32 to a $35 (backquote to escape) d) Change the byte at offset $39 from a $35 to a $32 (escape to backquote) e) Change the byte at offset $38 from a $34 to a $2A (enter to slosh) f) Change the byte at offset $2E from a $2A to a $34 (slosh to enter) g) Open the ROv# ID=890. g) Open the ROv# ID=1660 h) This should open as a template showing fields like 'Version', 'NumTypes', followed by many entries consisting of 'Type' and 'Res ID' pairs. [If you do not get a template mail me and I'll send you the appropriate TMPL resource to install in your ResEdit Preferences file.] i) Select the last set of '*****'. j) Select 'Insert New Fields' from the Resource menu. k) Set the type to KMAP and the Res ID to 0 l) Save and close the System file 1.2 Changing the Key Cap Description ------------------------------------ Note: The instructions in this section will work only if you have a PowerBook with the US keyboard. If you have one with the ISO keyboard mail me and I'll try to help you. a) Open the System file in ResEdit b) Open the resource KCAP ID=12 (ignore the warning about the resource being compressed) c) Change the byte at offset $1B from a $32 to a $35 (backquote to escape) d) Change the byte at offset $141 from a $35 to a $32 (escape to backquote) e) Change the byte at offset $147 from a $34 to a $2A (enter to slosh) f) Change the byte at offset $69 from a $2A to a $34 (slosh to enter) g) Save and close the System file 1.3 Precautions When Updating Systems ------------------------------------- Once you have completed this exercise and determined whether it has worked successfully you should take a copy of the resources you changed and save them in separate resource file. This way, when you need to reinstall system software, you can just paste in these changes. Be more wary if you upgrade to a later system. The KMAP and KCAP resources are unlikely to change between systems but the ROv# may well do so. In that case you would have to change the ROv# again by following steps g) through to k) above. 1.4 Theory of Operation ----------------------- As documented in TN160 there is a resource called the KMAP which maps physical to virtual keycodes. This is distinct from the KCHR which maps virtual keycodes into ASCII characters. Bashing the KMAP resource is definitely the correct way of moving keys around the keyboard. The following is a list of keycodes associated with keys that need moving:- o backquote 50 $32 o escape 53 $35 o slosh 42 $2A o enter 52 $34 Normally the keyboard sends down a physical keycode of $32 which is mapped to the virtual keycode of $32. My procedure involves bashing the KMAP resource so that it maps $32 to $35 thereby mapping backquote to escape. I do this for each key I wish to remap. In addition there is another resource called the KCAP which is used by the Key Caps DA to display the physical positioning of the keys on the keyboard. This needs to be changed in line with the changes to the KMAP resource. The only problem remaining is that the PowerBook have a KMAP resource in ROM that the system uses by default. I change this by adding an entry to the ROv# resource stating that the KMAP ID=0 resource in the system file overrides the KMAP ID=0 resource in the ROM. See Inside Mac V-190 for information about physical and virtual keycodes. See Technote 160 'Key Mapping' for a description of the format of a KMAP resource. See Inside Mac IV-20 for information about the ROv# resource. 2. Hardware Remapping --------------------- Warning: The key caps are moderately delicate. Please use gentle persuasion (or brute force *with* finesse) to perform this surgery. I did these operation while the PowerBook was on and running. The reason for this is simple. If the PowerBook is in sleep (or off in the case of the PB100) then messing around with the keys will invariable turn it on. If you're squeamish about working on running hardware then you can i) remove the battery (if you own a PB100) OR ii) shut down the machine (for PB140/PB170 owners). To remove a key cap... a) Get a couple of lever type things (small flat head screwdrivers are good). b) Insert one on each side (ie left and right looking from the front) of the key cap you wish to remove. c) Lever up both sides simultaneously. Be careful that the key cap does not fly off into hyperspace. Also be careful that you do not apply too much force to the surrounding keycaps. To reinsert a key cap... a) Place key cap on key unit b) Rotate the keycap so that the writing on the cap is the right way up c) Push down gently until it locks in place Repeat for all the keys you wish to swap. Obviously only some are compatible (ie don't go round swapping space and Q :-) 3. CapsLock/Control Problems ---------------------------- At the moment it is not possible to swap capslock/control. The reason for this is simple. When you first press the capslock key it sends only a keydown event. When you next press it it only sends a keyup. This means that although you can swap capslock and control you end up with a control key that locks down and a capslock key that doesn't. A number of people at Apple are (informally) chasing up solutions to this problem. It may be possible to send the keyboard processor an instruction to get around the problem. However no definite solution has been found. 4. Creeping Legalitis --------------------- (C) Copyright 1992 Quinn "The Eskimo!" . This document may be freely distributed in any way as long as the copyright notice is retained. Neither the Department of Computer Science nor The University of Western Australia have anything to do with this document. I take no responsibility for any damage you might do to your hardware or software by following these instructions. My only claim is that I followed them and they worked for me (twice). If you have any problems, or feedback in general, feel free to mail me. Please distribute this note to your PowerBooking friends. Share and Enjoy. Quinn "The Eskimo!" "Real Coke, Diet .sig" Department of Computer Science, The University of Western Australia ======================================================================