Changing keyboard modifier keys

I use an editor (EMACS) which makes major use of the 'ctrl' key so I swap it with the 'caps lock' key so my little finger can hit it without getting a cramp. It works just fine about 90% of the time but the other 10%, when I hit the 'caps lock' key instead of getting the 'ctrl' function I get the 'caps lock' function and my editing screws up terribly. It is really frustrating because if I don't notice, and if I hit what I think is <ctrl>k to kill a line I get a 'K' in the text instead.
PowerBook G4    

I solved this problem by finding and altering an applescript that will change the keyboard modifier keys. I wish I could still find the web page so I could post it, but here's the applescript I used to change to PC layout:
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
tell process "System Preferences"
click radio button "Keyboard" of tab group 1 of window "Keyboard & Mouse"
click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
click pop up button 3 of sheet 1 of window "Keyboard & Mouse"
click menu item 4 of menu 1 of pop up button 3 of sheet 1 of window "Keyboard & Mouse"
delay 1
click pop up button 4 of sheet 1 of window "Keyboard & Mouse"
click menu item 3 of menu 1 of pop up button 4 of sheet 1 of window "Keyboard & Mouse"
click button "OK" of sheet 1 of window "Keyboard & Mouse"
end tell
end tell
tell application "System Preferences"
quit
end tell
(end of script)
And here's the script I used to change it back to Mac layout:
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
tell process "System Preferences"
click radio button "Keyboard" of tab group 1 of window "Keyboard & Mouse"
click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
click button "Restore Defaults" of sheet 1 of window "Keyboard & Mouse"
click button "OK" of sheet 1 of window "Keyboard & Mouse"
end tell
end tell
tell application "System Preferences"
quit
end tell
(end of script)
I saved the scripts as executibles with neat Apple and XP custom icons and put them in the Dock. Pretty slick.

Similar Messages

  • Script to change keyboard modifer keys?

    I'm trying to create a login script to use with Workgroup Manager that will allow me to change the keyboard modifer keys on a client machine. I've done a search and found a few scripts but they don't seem to work. For example the following script:
    tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.keyboard"
    tell application "System Events"
    tell process "System Preferences"
    click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
    set curOpt to (get value of pop up button 3 of sheet 1 of window "Keyboard & Mouse")
    set curCmd to (get value of pop up button 4 of sheet 1 of window "Keyboard & Mouse")
    tell sheet 1 of window "Keyboard & Mouse"
    tell pop up button 3
    click
    click menu item curCmd
    end tell
    tell pop up button 4
    click
    click menu item curOpt
    end tell
    end tell
    click button "Ok" of sheet 1 of window "Keyboard & Mouse"
    end tell
    end tell
    quit
    end tell
    I am trying to get this to work on OS X 10.6 with no luck. Firstly I have seperate options in System Preferences for Keyboard and Mouse settings (the script above points to window "Keyboard & Mouse") and secondly, even after changing the "Keyboard & Mouse" to just "Keyboard" I get an error message about not being about to locate button "Modifier Keys...".
    All I'm trying to do is change the Modifier Keys so that Crtl key is set to nothing. Could anyone help me out?

    This could work... (tested with 10.6.7)... not very fast...
    another idea could be a defaults write command, but I am not sure which prefs-file you would have to edit.. maybe .GlobalPreferences.plist...
    tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.keyboard"
    tell application "System Events"
    tell process "System Preferences"
    click button 1 of tab group 1 of window 1
    set curOpt to (get value of pop up button 3 of sheet 1 of window 1)
    set curCmd to (get value of pop up button 4 of sheet 1 of window 1)
    click pop up button 4 of sheet 1 of window 1
    my setbuttonitem(1)
    click pop up button 3 of sheet 1 of window 1
    my setbuttonitem(2)
    click pop up button 2 of sheet 1 of window 1
    my setbuttonitem(3)
    click pop up button 1 of sheet 1 of window 1
    my setbuttonitem(4)
    delay 0.25
    keystroke return
    end tell
    end tell
    quit
    end tell
    on setbuttonitem(valueindex)
    tell application "System Events"
    tell process "System Preferences"
    repeat with i from 1 to 5
    key code 126
    delay 0.25
    end repeat
    repeat with i from 1 to valueindex - 1
    key code 125
    delay 0.25
    end repeat
    keystroke return
    end tell
    end tell
    end setbuttonitem

  • Keyboard modifier keys

    I have a new MacbookPro that I sometimes use with a bluetooth keyboard (Logitech DiNovo Edge). Because the bluetooth keyboard is set for Windows, I used the keyboard Preference Pane to switch the modifier keys for option and command (or Apple) keys. (That is, on the bluetooth keyboard I made the Option key work as the Command key and vice versa.)
    My problem is that now I cannot switch the preference setting back. When I use the MBP without the bluetooth keyboard, I want the keys to work as designed. So I go to the Preference Pane and manually change the modifier keys settings, or click "Restore Default" but it continues to still be stuck at the setting that I had set for the bluetooth keyboard.
    I have tried restarting the computer after restoring default. I have also removed the keyboard preferences (plist file) from the ~/Library folder. None of this makes a difference. I cannot restore the default key behavior.
    Since I use the Command key a lot (to cut, paste, copy etc.) this is seriously affecting my work productivity. I will appreciate any help.

    VK, That terminal command did not work for me.
    However, I found the solution on another post and it worked. The solution is here:
    http://discussions.apple.com/thread.jspa?messageID=8560965&#8560965

  • Keyboard Modifier Keys trouble

    Hi!
    I have gotten a new problem, I never had before.
    While having an external USB-keyboard plugged in, I swapped the Option and Command keys here:
    System Preferences -> Keyboard & Mouse -> Keyboard -> Modifier Keys
    (I find this useful when I use external PC keyboards via KVM switches and such, as they have the Windows key and Alt key opposite, at least on Norwegian keyboards.)
    And usually that only applies to the external keyboard. But now, on my new macbook, it now applies to the built in keyboard. And I am not able to turn it off. Or: When I turn it off or choose Restore Defaults, nothing happens. Even though Command is listed as the Command key, Option still works as the Command key, and Option as the Command key.
    So, does anyone know if there's a file I might delete or modify or something?
    flips 8)

    It seems the settings are stored in ~/Library/Preferences/ByHost/.GlobalPreferences.<UUID>.plist
    First I deleted both com.apple.keyboard.modifiermapping trees/entries.
    Then I re-entered the correct setting for only the external keyboard. (My guess is that I just overlooked the option of changing mapping for just one of the keyboards or "All".) Still I would consider it a bug not being able to reverse the setting without manually deleting it from the correct plist file ...
    flips 8)

  • Getting the keyboard modifiers key state before injecting event.

    I'm using the Robot to inject keyboard events into a host computer from multiple clients.
    Since each client can have different modifiers keys (i.e. Shift, Alt, Ctrl, ...) set at a time and
    clients can interrupt each other, I need to be able to read from the host computer what
    modifier keys are set at that moment to get things back into synch.
    The KeyEvent class has a way to get the modifier keys through:
    KeyEvent.isShiftDown();
    KeyEvent.isControlDown():
    But this doesn't help (apparently) because that information is only available to a
    Keyboard listener when a key is pressed.
    What I need is a way to "get" the current keyboard modifier keys state before injecting
    an event through the Robot.
    Would anyone know how to do this?

    So... the clients send input events to the host and the host in turn simulates those events with the use of a Robot. Is that correct?
    If so then the program needs to save the last injected keyboard input that had a modifier mask in a field somewhere. Whenever you need to ask if any modifier keys are being pressed, you need only to look at this field and see if it is a pressed event. However, this method won't be able to detect a person physically at the host computer typing stuff.
    The central problem is that you can query keyboard input from OS (such as asking if shift is currently pressed) without a focused window using the standard api. But a focused window kind of defeats the purpose of what you are trying to do.

  • Is there a way to add/change the modifier keys?

    Hi
    I would like to have the smooth tool be a modifier key like it used to be. aaah the old days.
    anyway I'm sure I'm not the only one.
    Thanks!

    You can assign a keyboard shortcut. Go to your Edit menu in Illustrator, select keyboard shortcuts. Scroll down to the smooth tool and enter the key combo that you would like to use. Then save the set.

  • Keyboard modifier key remap suddenly not working

    I am using a MacBook Pro running OS X 10.6.8 (Snow Leopard). I use a third-party USB keyboard that is laid out (naturally) Windows-style, with the Alt keys inside (closer to the space bar than) the “Windows logo” keys. I use the Modifier Keys button in the Keyboard preference panel to remap these to the standard Mac configuration, with the Command keys on the inside and the Option keys on the outside.
    Today those modifier keys are suddenly reversed back to the default Windows layout. The Keyboard panel still shows my preferred (remapped) configuration, but it is not being honored. I have tried reverting to the default layout and then back again, I have rebooted the system, nothing works—the modifier keys are still stuck in the Windows configuration. I rely heavily on keyboard macros in my work, most of which use the modifier keys, and those keystrokes are built into my fingers as second nature. The reversed modifier keys are driving me crazy. Please help: what can I do to make the keyboard honor my settings in the Keyboard preference panel?

    Same problem here. Been working fine for a couple years and now suddenly the modifier key mapping is being ignored.

  • Unable to change modifier keys on exernal keyboard.

    Running a unibody MBP with 10.8.5.  Trying to change the modifier keys (swap Option and Command) on an external USB keyboard (daskeyboard ultimate stealth).  Using Preferences -> Keyboard/Mouse -> Modifier Keys, I select my external keyboard (listed as daskeyboard) and make the switch.  This has no effect.  I am able to change the modifiers on the built in keyboard, but that doesn't help me. 
    I am not running the KB through a hub, direct connect to USB port.
    I have tried all possible combinations of adjust settings, reboot, retry, unplug, re-plug, move plug - no joy.
    From other posts here and elsewhere it seems this bug/glitch has been in Apple's side for a lot of years.  Does anyone have a FIX for this that does not involve some hacky workaround where a chicken needs to die?
    I run a linux VM on this Mac and it would be really nice if CTRL and ALT were where CTRL and ALT have been for decades.

    Hello
    I have a new Toshiba Satellite A75-S209 laptop. Now the keyboard was working perfectly, until i plugged in a external logitech usb keyboard. Now when i try to use the laptop keyboard alone all the characters are messed up.
    i have tried to reinstall the keyboard by removing it, but i was not successful .
    is there any way of re mapping all the keys?
    or even like keyboard software?!
    thanks
    nelby

  • Swapping modifier keys by keyboard doesn't work.

    At some point, Apple added the ability for the user to configure the modifier keys differently on different keyboards. So you can, for example, swap the Alt and Windows keys on a windows keyboard, but leave them alone for your Mac keyboards. This is great, as I have been frustrated by this for a long time. My only problem is, it has never worked for me!
    More specifically:
    1. Open Keyboard & Mouse Preferences
    2. Choose the Keyboard tab
    3. Click the Modifier Keys... button
    4. For Select keyboard, choose the keyboard you are currently using.
    5. Change some of the key options below. In my case, I changed Option to Command, and Command to Option.
    6. Click OK.
    7. Try it
    Making this change has no effect for me. I've even verified that the changes actually "stick". The only time I'm actually able to change these keys, is if I choose All for Select Keyboard.
    Has anyone else seen this? Or can anyone suggest how to fix it?

    Yesterday I plugged one Microsoft USB keyboard for the first time ever to my MB Pro at the office and operated my laptop lid down. I swapped the Control and Command keys as it felt more natural to press Ctrl on a PC keyboard than Windows or Alt keys. I unplugged the keyboard (still lid down) and went home.
    Today I have been facing this same problem. No matter what I do (reboot, adjust the keyboard modifier keys settings etc.) the Cmd stays in the Ctrl key and vice versa on my laptop keyboard.
    Very annoying, I have not invented a cure. Can anybody point me to the preference file that should have this setting recorded? I'd like to try to delete it.
    What I am going to do next is to go back to the office, plug the keyboard on again and try adjusting these keys back to original. My theory is that the MS keyboard driver has messed something on a "deeper level" or done it in some non-standard way, but I have no access to that setting until there is a MS keyboard plugged in that activates the driver and meddles with the settings in that way again. I will report my findings.
    Any suggestions at this stage?

  • Modifier keys not working after 10.6.7 update

    After the most recent 10.6.7 update, my modifier keys no longer work. I switched my Command and Option keys over a year ago, but now even when I'm in System Preferences>Keyboard>Modifier Keys and I switch them back and forth from Restore Defaults to the way I had them, nothing changes. I deleted  /username/Library/Preferences/ByHost/com.apple.HIToolbox.UUID.plist and logged off and back on, but that didn't work. Any suggestions?

    After the most recent 10.6.7 update, my modifier keys no longer work. I switched my Command and Option keys over a year ago, but now even when I'm in System Preferences>Keyboard>Modifier Keys and I switch them back and forth from Restore Defaults to the way I had them, nothing changes. I deleted  /username/Library/Preferences/ByHost/com.apple.HIToolbox.UUID.plist and logged off and back on, but that didn't work. Any suggestions?

  • Modifier Keys Not Restoring to Default

    I changed my modifier key mapping so that I could use a Windows keyboard with my MacBook Pro (late 2008). I set the Control key to function as the Command key and vice versa. Now it won't change back.
    I've changed the key selections. Restored Defaults under Keyboard & Mouse. I've performed a Disk Utility. I've confirmed nothing is selected under Speech.
    At a loss and kind of miffed. Makes using my laptop quite inconvenient when not at my desk.
    Any thoughts or suggestions?

    OK, I've solved the problem. Here's how you fix it:
    1. Plug in the external keyboard and set the modifier keys to work correctly with the external keyboard.
    2. Change the modifier keys back to default settings. Try the laptop keyboard to insure the modifier keys work correctly.
    3. Go back to the modifier keys section and in the "Select keyboard:" drop down pick the external keyboard.
    4. Change the modifier keys to work with the external keyboard.
    5. Test both keyboards, they should now work.
    You might not have to do all these steps, but that's what I did and it worked. Good luck.

  • Why can't I use AS to change Keyboard prefpane settings?

    Hey y'all, I got a question for you.
    I have a windows keyboard that I plug into my iBook at home. A very common arrangement, I'm sure.
    When I plug the keyboard in, I go into the Keyboard prefpane and use the controls there to swap the <COMMAND> and <OPTION> Keys, so the keys are more mac-like.
    What I want to do is pretty simple: Create an applescript to do that for me, so I don't have to, everytime, go Apple -> System Preference -> Keyboard & Mouse -> Keyboard -> Modifier Keys etc.
    As a total AS newbie, here are my questions:
    1. Can AS do this?
    2. If not, why not? This is a serious question: What good is AppleScript if it won't actually do the things -- especially an extremely simple thing like change a system preference -- that I want it to?
    3. Is there a better way to do this?
    Thanks for whatever guidance you can offer!
    Alaska Jack
    iBook G4   Mac OS X (10.4.6)  

    Hi Jack and welcome to Apple Discussions!
    To answer your questions:
    1) Apparently so. See this thread in the Automator forum.
    2) AppleScript is very good at automating repetitive tasks and inter-application communication - provided developers incorporate scriptability into their applications. In the case of System Preferences, Apple themselves haven't put in the "hooks" that allow preferences to be changed without resorting to UI scripting, as in the solution linked above.
    3) It might be possible to parse the preference files themselves.
    Hope this helps,
    H

  • How can I change the input key language between different languages ?

    the language can't be changed when i press ctrl+alt

    The default keys to rotate the layout is a key combination (Ctrl+Shift or Alt+Shift) that can easily be used in Firefox to activate a menu item.
    It is better to disable the key sequence to rotate layouts (Alt+Shift or Ctr+Shift) to avoid an unintentional switch and instead assign a specific key (Alt/Ctrl + Shift + number) to switch to the keyboard layout.
    Control Panel > Regional and Language Options > Keyboards and Languages > Change keyboards > Advanced key settings > Change key sequence
    http://support.microsoft.com/kb/258824 - How to change your keyboard layout
    You can also use the Language bar on the Windows Taskbar.<br />
    You can make the Language bar visible via the right-click context menu of the Taskbar: Toolbars > Language Bar.
    * http://windows.microsoft.com/en-US/windows7/The-Language-bar-overview The Language bar (overview)

  • Lion update - modifier keys ignored

    I have a Logitech Cordless MediaBoard Pro - though there's no command key, in 10.6 I had remapped the caps lock key to the command key. In Lion, this same setting (System Preferences -> Keyboard -> Modifier Keys) doesn't seem to be functioning. The default key mappings and their associated functions do seem TO BE RECOGNIZED (hardy har har) - so I don't think it's entirely keyboard driver specific. Help? I'd really like to copy, paste, switch apps, and quit apps seamlessly!

    Yes, I think that I figured out that for some reason there were two keyboards listed. Also, once I installed the Microsoft Keyboard preferences plugin, it seemed to work allright as well.
    I've bought a new Mini since then, and haven't seen those issue there (I use my old mini as a headless server, so no keyboard attached).

  • Changing modifier keys in keyboard preference pane has no effect

    I use a standard "windows" usb external keyboard. In 10.5 you could remap the "Command" and "Option" keys to match the "Mac" layout. In 10.6 the preference pane is still available, but no matter how you change the pop-up menus the keyboard layout is not changed. See http://iamwa.de/45
    I have verified this to be the case with three different USB keyboards.

    @mtrichardson: THANK YOU!!! I've been having problems my modifier keys for months, and was using the section of the modifiers that affected ALL keyboards to swap the modifier keys. That section was apparently removed in snow leopard which left me high and dry until I saw your post. I tried unplugging the mouse and THEN configuring the USB keyboard, and that did the trick!
    Mouse is a logitech mx revolution, which I love, but it apparently causes some strange side effects. I should never have installed Logitech's drivers.
    Thanks again,
    -- Mike

Maybe you are looking for

  • Apache service is not running

    Hi After running autoconfig apache is not running. error is E:\oracle\prodcomn\admin\scripts\PROD_sysa>adapcctl.cmd start ECHO is off. ECHO is off. Sun 12/16/2007 9:04a Starting Oracle Apache Server PROD_sysa ... The service name is invalid. More hel

  • Trouble charging ipod on computer

    my ipod is hooked up to a my computer and will only charge while the ipod is updating and then it stops charing. i can't seem to figure out how to charge it up on the computer.

  • Active Directory Integrated DNS Zones, replicate only to specific domain controllers

    I have a customer with a fairly large Active Directory forest with many domains that they are trying to consolidate into a single domain which likely take 18 to 24 months according to their timeline.  During this time, they would like all DNS zones t

  • Reading/writing .ico files

    I'm working on a coldfusion system where users can upload their own favicon files for their site. To allow compatibility with IE I want to allow for .ico files but I need to determine their dimensions so that I can limit the size. The restrictions of

  • WebCRM Demo license

    Hi All, I have setup WebCrm on a test server with a demo license just to see if I can get it all working. I know I have to access the site locally and not across a network but besides this restriction, will all other functionality within the product