Skip to content

Instantly share code, notes, and snippets.

@oneleo
Last active August 5, 2023 01:25
Show Gist options
  • Save oneleo/d0586775beb1fe16d8f06f5b14a3c5b9 to your computer and use it in GitHub Desktop.
Save oneleo/d0586775beb1fe16d8f06f5b14a3c5b9 to your computer and use it in GitHub Desktop.
karabiner-elements: partial solution while changing language inputs between EN and ZH
{
"title": "LR_Shift to Ctrl+Space",
"rules": [
{
"description": "Change L_Shift to switch EN/ZH condition",
"manipulators": [
{
"type": "basic",
"conditions": [
{
"input_sources": [
{
"input_source_id": "^com\\.apple\\.keylayout\\.ABC$",
"language": "en*"
}
],
"type": "input_source_unless"
}
],
"from": {
"key_code": "left_shift",
"modifiers": {
"optional": ["any"]
}
},
"parameters": {
"basic.to_if_alone_timeout_milliseconds": 333,
"basic.to_if_held_down_threshold_milliseconds": 333
},
"to": [
{
"key_code": "left_shift",
"lazy": true
}
],
"to_if_held_down": [
{
"key_code": "left_shift"
}
],
"to_if_alone": [
{
"select_input_source": {
"input_source_id": "^com\\.apple\\.keylayout\\.ABC$",
"language": "en*"
}
}
]
},
{
"type": "basic",
"conditions": [
{
"input_sources": [
{
"input_source_id": "^com\\.boshiamy\\.inputmethod\\.BoshiamyIMK$",
"language": "zh*"
}
],
"type": "input_source_unless"
}
],
"from": {
"key_code": "left_shift",
"modifiers": {
"optional": ["any"]
}
},
"parameters": {
"basic.to_if_alone_timeout_milliseconds": 333,
"basic.to_if_held_down_threshold_milliseconds": 333
},
"to": [
{
"key_code": "left_shift",
"lazy": true
}
],
"to_if_held_down": [
{
"key_code": "left_shift"
}
],
"to_if_alone": [
{
"select_input_source": {
"input_source_id": "^com\\.boshiamy\\.inputmethod\\.BoshiamyIMK$",
"language": "zh*"
}
},
{
"key_code": "spacebar",
"modifiers": ["left_command"],
"hold_down_milliseconds": 11
},
{
"key_code": "spacebar",
"modifiers": ["left_command"]
}
]
}
]
},
{
"description": "Change R_Shift to switch EN/ZH condition",
"manipulators": [
{
"type": "basic",
"conditions": [
{
"input_sources": [
{
"input_source_id": "^com\\.apple\\.keylayout\\.ABC$",
"language": "en*"
}
],
"type": "input_source_unless"
}
],
"from": {
"key_code": "right_shift",
"modifiers": {
"optional": ["any"]
}
},
"parameters": {
"basic.to_if_alone_timeout_milliseconds": 333,
"basic.to_if_held_down_threshold_milliseconds": 333
},
"to": [
{
"key_code": "right_shift",
"lazy": true
}
],
"to_if_held_down": [
{
"key_code": "right_shift"
}
],
"to_if_alone": [
{
"select_input_source": {
"input_source_id": "^com\\.apple\\.keylayout\\.ABC$",
"language": "en*"
}
}
]
},
{
"type": "basic",
"conditions": [
{
"input_sources": [
{
"input_source_id": "^com\\.boshiamy\\.inputmethod\\.BoshiamyIMK$",
"language": "zh*"
}
],
"type": "input_source_unless"
}
],
"from": {
"key_code": "right_shift",
"modifiers": {
"optional": ["any"]
}
},
"parameters": {
"basic.to_if_alone_timeout_milliseconds": 333,
"basic.to_if_held_down_threshold_milliseconds": 333
},
"to": [
{
"key_code": "right_shift",
"lazy": true
}
],
"to_if_held_down": [
{
"key_code": "right_shift"
}
],
"to_if_alone": [
{
"select_input_source": {
"input_source_id": "^com\\.boshiamy\\.inputmethod\\.BoshiamyIMK$",
"language": "zh*"
}
},
{
"key_code": "spacebar",
"modifiers": ["right_command"],
"hold_down_milliseconds": 11
},
{
"key_code": "spacebar",
"modifiers": ["right_command"]
}
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment