Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

On my Linux computer, my keyboard switches from English to Serbian when I hold the Caps Lock key. For example, to write č all I have to do is hold Caps Lock, and press the key where č is on the Serbian keyboard (in this case, they key is ; on the English keyboard). When I release Caps Lock, the keyboard "switches back" to English, so that if I press ; I get ; as desired. Super useful.

Is there a way to replicate this behavior on OS X?

share|improve this question

2 Answers

up vote 0 down vote accepted

You could make your own keyboard layout with Ukelele or edit the keylayout files that come with it in a text editor. You'd have to use another modifier key like the right option though.

  1. Open Serbian.keylayout and U.S..keylayout from Ukelele's disk image in a text editor.
  2. Copy keyMap and keyMapSelect elements from the Serbian layout to the U.S. one, and increment their indexes, and add rightOption to the modifier tags in the keymaps.
  3. Change the modifier keys of the original keymaps so they only use the left option.
  4. Change the name and id of the new layout and save it to /Library/Keyboard Layouts/.
  5. Log out and back in and enable the input source in the Language & Text preferences.

Applying changes to a keylayout file currenly requires logging out and back in after for example adding or removing a file in ~/Library/Keyboard Layouts/ or running touch ~/Library/Keyboard\ Layouts/.

It gets even more complicated though:


I found a nicer way to do it with KeyRemap4MacBook:

<?xml version="1.0"?>
<root>
<item>
<name>test</name>
<identifier>private.test</identifier>
<autogen>--KeyToKey-- KeyCode::F1, KeyCode::VK_NONE, Option::KEYTOKEY_BEFORE_KEYDOWN, KeyCode::VK_CHANGE_INPUTMODE_GERMAN, Option::KEYTOKEY_AFTER_KEYUP,    KeyCode::VK_CHANGE_INPUTMODE_ENGLISH</autogen>
</item>
</root>

VK_CHANGE_INPUTMODE_SERBIAN doesn't currently work, but you might be able to add Serbian to inputsourcedef.xml. You can remap caps lock to an F-key with PCKeyboardHack.

share|improve this answer
Actually, this seems close to what I want (although it's a tad too involved to be practical). – Syzygy Aug 9 '12 at 2:57
The KeyRemap4MacBook is the way to do it, I think. A similar solution with AutoHotKey works on Win 8 for me. – Syzygy Oct 25 '12 at 16:02

You can easily switch from the Serbian keyboard to the US keyboard or vice versa by pressing Command-Space. To set this up:

Go to System Preferences..., Language & Text, Input Sources, and select both the Serbian and English keyboard layouts. Select the check box next to Show Input menu in menu bar. Make sure that under Input source shortcuts that Select previous input source: is set to Command-Space.

This is all you need to do.

enter image description here

share|improve this answer
This actually isn't what I am asking for. I know you can toggle to, and from, a keyboard layout. What I want is to hold Caps Lock as a modifier key. For example, Shift modifies the letter pressed to upper case. I want Caps Lock to modify the keyboard to be Serbian, for the duration of the press. – Syzygy Aug 9 '12 at 2:58
You can define a different modifier key other than Command-Space, by clicking on the Keyboard Shortcuts button in the dialog shown above. – Wheat Williams Aug 9 '12 at 17: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.