Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: Set different modifier keys for external keyboards System 10.5
I use a PC keyboard to go with my MacBook at home, which is fine until I need to use a keyboard shortcut that starts with Command. Then I sometimes get pretty confused figuring out just where the Command key is.

In Leopard, I can set different Modifier Keys for different keyboards, so I remap ALT to Command and WIN to Option on my PC keyboard. Here's how:
  1. Plug in a external keyboard to your Mac
  2. Go to System Preferences and open the Keyboard & Mouse pane
  3. Click Modifier Keys under the Keyboard tab
  4. Select External Keyboard, and change the modifier keys
End of confusion!
    •    
  • Currently 3.67 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[10,929 views]  

10.5: Set different modifier keys for external keyboards | 7 comments | Create New Account
Click here to return to the '10.5: Set different modifier keys for external keyboards' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Set different modifier keys for external keyboards
Authored by: Shiver758 on Oct 26, '07 08:02:19AM

Yet another example of mind reading from the fine folks in Cupertino.

I can't count the number of times I've thought.. "Hey.. they should have.. ".. And it magically appears.

I'm so happy to have Leopard on my iBook tonight, and this hint (along with that AWESOME hint about using ScreenSharing as a VNC viewer) makes it all the sweeter.

Thanks!



[ Reply to This | # ]
10.5: Set different modifier keys for external keyboards
Authored by: Jwink3101 on Oct 26, '07 12:02:43PM

Maybe it is becuase i have drivers installed for my external keyboard but on my 12" PowerBook, with 10.4.10, i do not see an option to select just the external keyboard



[ Reply to This | # ]
10.5: Set different modifier keys for external keyboards
Authored by: osxpounder on Oct 26, '07 02:45:52PM

I think you need 10.5 for this hint to work [hence the "10.5" in the title]. ;)



[ Reply to This | # ]
10.5: Set different modifier keys for external keyboards
Authored by: Anonymous on Oct 26, '07 08:05:23PM
For people not upgrading...
I have an external keyboard, that I swap the command/alt keys (so the laptop and external keyboard command buttons are next to the spacebar)

I was doing this manually, which got tedious quickly. I found a script that automatically swapped they keys. Since I found it slightly confusing (ended up swapping it away from the right settings and such), among other problems (it reset my spacebar-as-shift option) - I rewrote it a bit.


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
			
			-- 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 commandKey to value of pop up button 3
				-- looks like we're in laptop mode.  Swap the keys
				click pop up button 3
				click menu item 4 of menu 1 of pop up button 3 -- command key to alt
				delay 1
				click pop up button 4
				click menu item 3 of menu 1 of pop up button 4 -- alt key to command
				-- close the sheet
				click button "OK"
			end tell
		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
I saved it as lt_to_pc.scpt, and the same script. And another version with the "of popup button 3" changed to button 4, and "button 4" to button 3 - saved as pc_to_lt.
I run it automatically via MarcoPolo (two zones, PC_keyboard, and LT_keyboard - when it arrives in PC_keyboard, it runs lt_to_pc, and for LT_keyboard, pc_to_lt, The zones are switched by the USB keyboard device of course) - but I'm considering just running it via Quicksilver, unless I can think of other uses fo MarcoPolo (Currently I don't have any other need for it, so running it just to swap the keyboard keys is slightly overkill I'd say)..

Apologies for the slightly incoherent post.. - Ben

[ Reply to This | # ]
10.5: Set different modifier keys for external keyboards
Authored by: Anonymous on Dec 19, '07 11:24:01PM
It seems some external keyboards don't get recognized by Leopard, so the automatic modifier switching doesn't work for them. Yury Soldak emailed me yesterday, with a modified version of the above code which works with the Leopard (the drop-down indexes changed because of the extra button, and there's a few other changes) Here's the code - to swap the command and option keys on an external keyboard on Leopard: (Its an AppleScript, copy and paste it into Script Editor and save/run it)
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
			
			-- 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"
				if pop up button 5 exists then
					-- looks like we have external keyboard.  Swap the keys for all
					click pop up button 5
					click menu item "All" of menu 1 of pop up button 5
					delay 1
					-- command key to alt
					click pop up button 1
					click menu item 3 of menu 1 of pop up button 1
					delay 1
					-- alt key to command
					click pop up button 2
					click menu item 4 of menu 1 of pop up button 2
					delay 1
					-- restore defaults for internal keyboard
					click pop up button 5
					click menu item "Apple Internal Keyboard / Trackpad" of menu 1 of pop up button 5
					delay 1
					click button "Restore Defaults"
				else
					click button "Restore Defaults"
				end if
				-- close the sheet
				click button "OK"
			end tell
		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


[ Reply to This | # ]
10.5: Set different modifier keys for external keyboards
Authored by: panis on Oct 27, '07 05:46:00PM

That option was presented in 10.4 (and isn't 10.5 exlusive).



[ Reply to This | # ]
10.5: Set different modifier keys for external keyboards
Authored by: Power Factor on Oct 27, '07 09:08:42PM

Note: Keyboards must be different types or they appear as one.



[ Reply to This | # ]