Well, in Keyboard & Mouse preferences you can swap the modifier keys (Option, Command, Control, and Caps Lock) to remedy this. In Tiger, you could only change this globally for all keyboards, meaning that when you switched between external and internal keyboards, you'd have to keep switching the settings if you wanted to keep the right key orientation. This gave rise to the Applescript below, from Lance Ball.
In Leopard, however, they added the ability to configure keyboards independently. You could, theoretically, leave your internal keyboard with the default setting, and only have them swapped for the external. Oh, if only this were the case. I run a Logitech Cordless Desktop MX3000, and used to, for a brief moment, have the option to do this. It was listed as "USB Reciever". However, the Logitech Control Center driver removed this. That's what brought me to the following script. This will automatically swap the Option and Command key mappings, toggling between them each time it is run. The original Lance Ball script was for Tiger, but has been adapted for Leopard. You can use this with MarcoPolo to run automatically when you add/remove your keyboard.
Update (9/29/08): I gave up using my MX3000 mouse, and went to a more ergonomic MS Natural Mouse. Since the MX3000 keyboard never worked with Logitech Control Center anyway, I just removed the driver. I've now reclaimed the ability to independently map my Logitech keyboard. Huzzah.
If you still need the Leopard script for some reason, here it is. I added code to swap the MBP’s keyboard illumination on/off (off for ‘docked’ mode. You can enable this feature as per the script comments since it's disabled by default.
Paste and save the following in Script Editor.
-- **********************************************************************************
-- Utility script to switch keyboard mapping for Command and Option keys.
-- Useful when you have a PC external keyboard that you use in one location, but
-- at other times you are using the builtin laptop keyboard or an Apple keyboard.
-- Author: Lance Ball (lanceball - at - mac - dot - com)
-- Modified by: Joe Chan
-- Modified attributes: Script will change Internal Keyboard to have default behavior when
-- changing keyboards
--
-- Leopard 10.5.5 version by netgarou. Also added feature to toggle Macbook Pro keyboard illumination.
-- (Remove the appropriate remark lines that start with "--**" to enable this if your system supports it).
-- Also disabled Growl notifications by default.
--
-- **********************************************************************************
-- Set up growl notifications
tell application "GrowlHelperApp"
-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to ¬
{"External Keyboard Mode Notification", "Default Keyboard Mode Notification"}
-- Make a list of the notifications
-- that will be enabled by default.
-- Those not enabled by default can be enabled later
-- in the 'Applications' tab of the growl prefpane.
set the enabledNotificationsList to ¬
{"External Keyboard Mode Notification", "Default Keyboard Mode Notification"}
-- Register our script with growl.
-- You can optionally (as here) set a default icon
-- for this script's notifications.
register as application ¬
"Change Keyboard AppleScript" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Script Editor"
end tell
-- Open System Preferences
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
-- If we don't have UI Elements enabled, then nothing is really going to work.
if UI elements enabled then
tell application process "System Preferences"
get properties
--If keyboard illumination is on, disable it when the external keyboard is connected.
--**if value of checkbox "Illuminate keyboard in low light conditions" of group 1 of tab group 1 of window "Keyboard & Mouse" is 1 then
--** click checkbox "Illuminate keyboard in low light conditions" of group 1 of tab group 1 of window "Keyboard & Mouse"
--**end if
-- Open up the Modifier Keys sheet
click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
tell sheet 1 of window "Keyboard & Mouse"
-- get the text of the 3rd pop up button
set areweDefault to "0"
set commandKey to value of pop up button 2
-- If we're in default mode, swap the keys
if commandKey ends with "Option" then
-- Change "All" keyboards
click pop up button 2
click menu item 4 of menu 1 of pop up button 2
delay 0.1
click pop up button 1
click menu item 3 of menu 1 of pop up button 1
delay 0.1
-- Send growl notification
--** tell application "GrowlHelperApp"
--notify with name ¬
--** "External Keyboard Mode Notification" title ¬
--** "External Keyboard Mode" description ¬
--** "Settings have been optimized for external keyboards" application name "Change Keyboard AppleScript"
--** end tell
--** delay 0.1
click button "OK"
else
-- We're in PC keyboard mode. Swap back to the defaults
click button "Restore Defaults"
--** set areweDefault to "1"
-- Send growl notification
--** tell application "GrowlHelperApp"
--notify with name ¬
--** "Default Keyboard Mode Notification" title ¬
--** "Default Keyboard Mode" description ¬
--** "Reverted to default keyboard settings" application name "Change Keyboard AppleScript"
--**end tell
click button "OK"
end if
-- close the sheet
end tell
--** If switching back into laptop keyboard mode, then reenable the keyboard illumination if it was disabled
--** if areweDefault is "1" then
--** if value of checkbox "Illuminate keyboard in low light conditions" of group 1 of tab group 1 of window "Keyboard & Mouse" is 0 then
--** click checkbox "Illuminate keyboard in low light conditions" of group 1 of tab group 1 of window "Keyboard & Mouse"
--** end if
--**end if
end tell
tell application "System Preferences" to quit
else
-- UI elements not enabled. Display an alert
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled.
Check \"Enable access for assistive devices\""
end tell
end if
end tell
No comments:
Post a Comment