Mapping keys to set different input languages on macOS

Walkthrough of Mapping Each Command Keys to Setting Different Input Languages on macOS

Prerequisite

Final Goal

  • Press Left Command to set Mac's input method to English.
  • Press Right Command to set Mac's input method to Korean.
  • Any other shortcut combinations would perform as usual.

Instructions

  • Go to ~/.config/karabiner/assets/complex_modifications. You can click Command+Shift+G within Finder to open a goto window.
  • Create a JSON file like the following here (open any text editor and save it as filename.json).
  • Go to Karabiner-Elements.app → Complex Modifications and press add rules.
  • Click the rules that you want to enable. The above text file will show under Multilingual Input Methods.
{
  "title": "Multilingual Input Methods",
  "rules": [
    {
      "description": "R Command to 한글",
      "manipulators": [
        {
          "type": "basic",
          "from": {
              "key_code": "right_command",
              "modifiers": {"optional": ["any"]}
            },
          "to": [{"key_code": "right_command", "lazy": true}],
          "to_if_alone": [{"select_input_source": { "language": "^ko$" }}]
        }
      ]
    },
    {
      "description": "L Command to English",
      "manipulators": [
        {
          "type": "basic",
          "from": {
              "key_code": "left_command",
              "modifiers": {"optional": ["any"]}
            },
          "to": [{"key_code": "left_command", "lazy": true}],
          "to_if_alone": [{"select_input_source": { "language": "^en$" }}]
        }
      ]
    }
  ]
}

Configuring more languages

Update Mar 7th, 2022

  • If you're bilingual, try looking into Eikana.
  • I switched to Eikana + Gureum configuration; there's a notorious 자소 분리 bug in macOS Korean Keyboard.