1

I want to use four language in my OS X system (English, Spanish, Chinese, and Japanese), and I know I can change the language with + Space. However, I have a pathological hatred for switching with it, because it requires me to select from so, so many choices! I also know I can change it from the menubar on the right of the bar, but it's much more disgusting than the + Space solution.

So I rather want to change it with easier shortcut, like the following:

  • left switches to English
  • right switches to Spanish
  • left + left + C switches to Chinese
  • right + right + C switches to Japanese.

I tried to use Karabiner (the descendent from KeyRemap4MacBook), but it doesn't work on the first attempt on Chinese, on which when I switches to Chinese, it remains English (the input source icon on the menubar changes, but the keyboard does not work). But for some reasons if I switch from English to Chinese to English to Chinese (two attempts), then the Chinese keyboard finally works.

So I don't like the idea of using Karabiner. So what is the better way to change the input source?

3 Answers 3

3

I ran into the same issue with Chinese and Japanese. (The icon on the menu bar changed but the input source was not actually changed until I switched to another input source and back.) It's a known bug according to a post at Karabiner's mailing list:

It's one of the most annoying bug of OS X.

Changing CJK input sources directly from program is not handled appropriately.

So, you need the following procedures.

Step1:
Enable "Select next source in Input menu" (command-option-space) on System Preferences > Keyboard > Shortcuts.

Step2:
Change input source by sending command-option-space.

<autogen>
  __KeyToKey__
  KeyCode::K, ModifierFlag::OPTION_L,
  KeyCode::VK_CHANGE_INPUTMODE_US,
  KeyCode::VK_WAIT_100MS,
  KeyCode::SPACE, ModifierFlag::COMMAND_R | ModifierFlag::OPTION_L,
  <!-- adjust wait for your machine -->
  KeyCode::VK_WAIT_10MS,
  KeyCode::VK_WAIT_10MS,
  KeyCode::VK_WAIT_10MS,
  KeyCode::SPACE, ModifierFlag::COMMAND_R | ModifierFlag::OPTION_L,
  <!-- adjust wait for your machine -->
  KeyCode::VK_WAIT_10MS,
  KeyCode::VK_WAIT_10MS,
  KeyCode::VK_WAIT_10MS,
  KeyCode::SPACE, ModifierFlag::COMMAND_R | ModifierFlag::OPTION_L,

  Option::NOREPEAT,
</autogen>

changeinput is affected by the same bug.

Another workaround is to just change to another input source and back:

<root>
  <vkchangeinputsourcedef>
    <name>KeyCode::VK_CHANGE_INPUTSOURCE_HIRAGANA</name>
    <inputsourceid_equal>com.apple.inputmethod.Kotoeri.Japanese</inputsourceid_equal>
  </vkchangeinputsourcedef>
  <vkchangeinputsourcedef>
    <name>KeyCode::VK_CHANGE_INPUTSOURCE_SPANISH</name>
    <inputsourceid_equal>com.apple.keylayout.Spanish</inputsourceid_equal>
  </vkchangeinputsourcedef>
  <vkchangeinputsourcedef>
    <name>KeyCode::VK_CHANGE_INPUTSOURCE_US</name>
    <inputsourceid_equal>com.apple.keylayout.US</inputsourceid_equal>
  </vkchangeinputsourcedef>
  <vkchangeinputsourcedef>
    <name>KeyCode::VK_CHANGE_INPUTSOURCE_CHINESE</name>
    <inputsourceid_equal>com.apple.inputmethod.TCIM.Pinyin</inputsourceid_equal>
  </vkchangeinputsourcedef>
  <item>
    <name>inputsources</name>
    <identifier>inputsources</identifier>
    <autogen>__KeyOverlaidModifier__ KeyCode::COMMAND_L, ModifierFlag::COMMAND_L | ModifierFlag::NONE, KeyCode::VK_CHANGE_INPUTSOURCE_US, KeyCode::COMMAND_L</autogen>
    <autogen>__KeyOverlaidModifier__ KeyCode::COMMAND_R, ModifierFlag::COMMAND_R | ModifierFlag::NONE, KeyCode::VK_CHANGE_INPUTSOURCE_SPANISH, KeyCode::COMMAND_R</autogen>
    <autogen>__KeyToKey__ KeyCode::C, ModifierFlag::OPTION_L | ModifierFlag::COMMAND_L | ModifierFlag::NONE, KeyCode::VK_CHANGE_INPUTSOURCE_CHINESE, KeyCode::VK_CHANGE_INPUTSOURCE_US, KeyCode::VK_CHANGE_INPUTSOURCE_CHINESE</autogen>
    <autogen>__KeyToKey__ KeyCode::C, ModifierFlag::OPTION_R | ModifierFlag::COMMAND_R | ModifierFlag::NONE, KeyCode::VK_CHANGE_INPUTSOURCE_HIRAGANA, KeyCode::VK_CHANGE_INPUTSOURCE_US, KeyCode::VK_CHANGE_INPUTSOURCE_HIRAGANA</autogen>
  </item>
</root>
3
  • Your second solution disables the command key for all the other shortcuts (like +W to close the window), which is definitely not what I want... As to the 1st solution, I'll try it later.
    – Blaszard
    Oct 9, 2014 at 16:31
  • As to your first solution, I'm not sure why you want to wait 160ms and switch it three times...
    – Blaszard
    Oct 9, 2014 at 17:30
  • Hmmm... I still have issues in the __KeyOverlaidModifier__ as noted above, but I switched Japanese and Spanish inputsource because Japanese inputsource can function properly if you set it from within Karabiner's preferences in the Japanese inputsource section. Thanks for the answer.
    – Blaszard
    Oct 10, 2014 at 13:22
0

is a "dead" key, a modifier key. It does nothing on its own, though as it keeps a count of how many times it's pressed, that would be possibly why it's working at the second attempt.

More to the point... why would you want to use to switch input language, thereby eliminating its use for any other function.

Why not use F-Keys, perhaps, instead?

A better solution might be one of these...

https://superuser.com/questions/224161/switch-to-specific-input-source

3
  • I don't stick to using the apple key. (maybe you might have mistaken (command key) with the apple key...?)
    – Blaszard
    Sep 19, 2014 at 13:05
  • Well, it's because is the easiest to type, and switching between different languages occur so, so frequently.
    – Blaszard
    Sep 19, 2014 at 13:12
  • my point still stands.
    – Tetsujin
    Sep 19, 2014 at 13:13
0

check this

switch with simple press left_shift -> us, right_shift->ua

"rules": [
                    {
                        "description": "Right Shift to UA",
                        "manipulators": [
                            {
                                "from": {
                                    "key_code": "right_shift",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "right_shift",
                                        "lazy": true
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "select_input_source": {
                                            "language": "uk"
                                        }
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    },
                    {
                        "description": "Right Shift to US",
                        "manipulators": [
                            {
                                "from": {
                                    "key_code": "left_shift",
                                    "modifiers": {
                                        "optional": [
                                            "any"
                                        ]
                                    }
                                },
                                "to": [
                                    {
                                        "key_code": "left_shift",
                                        "lazy": true
                                    }
                                ],
                                "to_if_alone": [
                                    {
                                        "select_input_source": {
                                            "language": "en"
                                        }
                                    }
                                ],
                                "type": "basic"
                            }
                        ]
                    }
                ]
            }

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .