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.

If possible I would like something similar to this: http://apple.stackexchange.com/a/4815/31313

Basically a simple script that detects when I'm in tmux, if I am change the CAPS lock key to be a CTRL key, else revert it.

However it is also important for me to use the CAPS lock key from time to time, in those occasions I would like to keep it pressed for 5 seconds, then it triggers a normal CAPS lock.

Would this be easy to do? Possible to do? I would prefer if I don't use any kind of extra software so that I can just put this in a script.

Extra info:

I would want to achieve this in a Mac Mini with OSX Snow Leopard, if possible also with Mountain Lion.

share|improve this question

1 Answer 1

If you have already changed caps lock to control, adding this to private.xml in KeyRemap4MacBook would make holding control (or caps lock) toggle caps lock:

<autogen>--HoldingKeyToKey-- KeyCode::CONTROL_L, KeyCode::CONTROL_L, KeyCode::VK_NONE, KeyCode::CAPSLOCK, Option::NOREPEAT</autogen>

The threshold for holding keys is 0.2 s by default, but it can be changed in the second tab.

(I suggested changing fn+control (fn+caps lock) to caps lock in the previous question at Ask Different:)

<autogen>--KeyToKey-- KeyCode::CONTROL_L, ModifierFlag::FN, KeyCode::CAPSLOCK</autogen>

If you just want to keep some key as caps lock, you can also change control to caps lock in System Preferences.

share|improve this answer
    
So, I would add <only>TERMINAL</only> after the autogen statement? Or inside it? Would this also work if iTerm is used instead of the Terminal app? Thanks for the tip, although I don't have an fn key with this keyboard (it's a couple of generations of iMac back), you think that would work if I did <kbd>Option+Shift+Caps lock</kbd> instead? –  Greduan Jan 7 '13 at 3:21
    
Before or after it. But <only>TERMINAL</only> is just Terminal.app, and there's no constant for iTerm. For option and shift, change ModifierFlag::FN to VK_OPTION | VK_SHIFT. –  Lri Jan 7 '13 at 3:29
    
OK, so I use <autogen>--HoldingKeyToKey-- KeyCode::CONTROL_L, KeyCode::CONTROL_L, KeyCode::VK_NONE, KeyCode::CAPSLOCK, Option::NOREPEAT</autogen><only>TERMINAL</only> if I want the functionality I requested in the post, after changing the holding key threshold. And I would <autogen>--KeyToKey-- KeyCode::CONTROL_L, VK_OPTION | VK_SHIFT, KeyCode::CAPSLOCK</autogen><only>TERMINAL</only> if I want to remap caps lock to CTRL and press <kbd>Option+Shift+Caps lock</kbd> to switch caps lock. Right? –  Greduan Jan 7 '13 at 3:35
    
If you wanted caps lock to function as caps lock outside Terminal, you'd need to use PCKeyboardHack to change caps lock to something like F19 and then remap F19. –  Lri Jan 7 '13 at 3:48
    
Ah I see, thanks! Although this does solve it, it doesn't do it with a script so I won't accept it, but it's definitely a workaround. Thanks for looking into this. :) –  Greduan Jan 7 '13 at 3:51

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.