Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In aquamacs, how can I remap the capslock key to meta? I can remap command to control using:

(setq mac-command-modifier 'ctrl)

Is there a similar way to remap the capslock?

EDIT: I know that I can remap keys in the system preferences, but I'd really like to confine the damage to aquamacs only. Just like mapping the command key to ctrl, but for capslock.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Aside from the "Modifier Keys" System Preferences section, I don't think an application can override the behaviour of the caps lock key..

I'm fairly sure the Caps Lock key event is not passed to applications, nor can they override the toggle effect.. Maybe you could do something whereby you monitor caps lock key state, and send alt when it changes.. but this is extremely convoluted, and slightly useless (it wouldn't work if you hold the key..)

Do you really need the caps lock key in other applications?

If so, perhaps you could write an AppleScript to toggle the Caps Lock key mapping? For example, in pseudo-code:

loop forever:
    if frontmost application == "Aquaemacs":
        keys.capslock = "Meta"
    else:
        keys.capslock = "Default

Shouldn't be difficult using AppleScript, the code from this Apple support thread should be a good start:

tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.keyboard"
end tell

tell application "System Events"

    tell application process "System Preferences"
    	get properties

    	click button "Modifier Keys..." of tab group 1 of window "Keyboard & Mouse"
    	tell sheet 1 of window "Keyboard & Mouse"
    		click pop up button 1
    		click menu item "No Action" of menu 1 of pop up button 1
    		delay 3
    		click button "OK"
    	end tell
    end tell
end tell
share|improve this answer
    
+1; I was worried about this. I think that you might be right, that caps lock doesn't get passed to the application. –  Rob Sep 13 '09 at 18:30

You can remap Caps Lock to Control, Option, or Command in the System Preferences window. It's in System Preferences -> Keyboard -> Modifier Keys... Hopefully that's what your looking for.

share|improve this answer
    
Actually, no, but thanks for the answer. I know about the preferences optino, but I'm trying to avoid remapping keys system wide. But +1, since I think that a lot of people don't know this. –  Rob Sep 12 '09 at 18:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.