Mapping keys to set different input languages on macOS
Prerequisite
- You need Karabiner installed.
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 clickCommand+Shift+G
within Finder to open agoto
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
- Add a JSON Property with your language of choice. The language identifier is likely some combination of ISO 639 and ISO 3166 (i.e., BCP 47).
- https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to/select-input-source/