Skip to content

Instantly share code, notes, and snippets.

@kxccc
Last active September 20, 2024 06:12
Show Gist options
  • Save kxccc/f38351a59ae3ed3a56fa9dc018d9415e to your computer and use it in GitHub Desktop.
Save kxccc/f38351a59ae3ed3a56fa9dc018d9415e to your computer and use it in GitHub Desktop.
{
"title": "适合 HHKB 和 Vim 用户的键盘映射",
"rules": [
{
"description": "短按 Control_L -> ESC 并切换英文输入法",
"manipulators": [
{
"conditions": [
{
"input_sources": [
{
"language": "en"
}
],
"type": "input_source_unless"
}
],
"from": {
"key_code": "left_control"
},
"to": [
{
"key_code": "left_control",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "escape"
},
{
"key_code": "f18"
}
],
"to_if_held_down": [
{
"key_code": "left_control"
}
],
"type": "basic"
},
{
"conditions": [
{
"input_sources": [
{
"language": "en"
}
],
"type": "input_source_if"
}
],
"from": {
"key_code": "left_control"
},
"to": [
{
"key_code": "left_control",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "escape"
}
],
"to_if_held_down": [
{
"key_code": "left_control"
}
],
"type": "basic"
}
]
},
{
"description": "短按 Caps -> ESC 并切换英文输入法 | 其它情况 Caps -> Control_L",
"manipulators": [
{
"conditions": [
{
"input_sources": [
{
"language": "en"
}
],
"type": "input_source_unless"
}
],
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": ["any"]
}
},
"to": [
{
"key_code": "left_control",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "escape"
},
{
"key_code": "f18"
}
],
"to_if_held_down": [
{
"key_code": "left_control"
}
],
"type": "basic"
},
{
"conditions": [
{
"input_sources": [
{
"language": "en"
}
],
"type": "input_source_if"
}
],
"from": {
"key_code": "caps_lock",
"modifiers": {
"optional": ["any"]
}
},
"to": [
{
"key_code": "left_control",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "escape"
}
],
"to_if_held_down": [
{
"key_code": "left_control"
}
],
"type": "basic"
}
]
},
{
"description": "短按 Command_L -> 切换英文输入法",
"manipulators": [
{
"conditions": [
{
"input_sources": [
{
"language": "en"
}
],
"type": "input_source_unless"
}
],
"from": {
"key_code": "left_command"
},
"to": [
{
"key_code": "left_command",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "f18"
}
],
"to_if_held_down": [
{
"key_code": "left_command"
}
],
"type": "basic"
},
{
"conditions": [
{
"input_sources": [
{
"language": "en"
}
],
"type": "input_source_if"
}
],
"from": {
"key_code": "left_command"
},
"to": [
{
"key_code": "left_command",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "vk_none"
}
],
"to_if_held_down": [
{
"key_code": "left_command"
}
],
"type": "basic"
}
]
},
{
"description": "短按 Command_R -> 切换中文输入法",
"manipulators": [
{
"conditions": [
{
"input_sources": [
{
"language": "zh-Hans"
}
],
"type": "input_source_unless"
}
],
"from": {
"key_code": "right_command"
},
"to": [
{
"key_code": "right_command",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "f18"
}
],
"to_if_held_down": [
{
"key_code": "right_command"
}
],
"type": "basic"
},
{
"conditions": [
{
"input_sources": [
{
"language": "zh-Hans"
}
],
"type": "input_source_if"
}
],
"from": {
"key_code": "right_command"
},
"to": [
{
"key_code": "right_command",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "vk_none"
}
],
"to_if_held_down": [
{
"key_code": "right_command"
}
],
"type": "basic"
}
]
},
{
"description": "搭配 Homerow 使用,短按 Option_R 点击,长按 Option_R 滚动",
"manipulators": [
{
"from": {
"key_code": "right_option"
},
"parameters": {
"basic.to_if_alone_timeout_milliseconds": 170,
"basic.to_if_held_down_threshold_milliseconds": 170
},
"to": [
{
"key_code": "right_option",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "spacebar",
"modifiers": ["left_command", "left_shift"]
}
],
"to_if_held_down": [
{
"key_code": "j",
"modifiers": ["left_command", "left_shift"]
}
],
"type": "basic"
}
]
},
{
"description": "Right Command + hjkl to arrow keys Vim",
"manipulators": [
{
"from": {
"key_code": "h",
"modifiers": {
"mandatory": ["right_command"],
"optional": ["any"]
}
},
"to": [
{
"key_code": "left_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "j",
"modifiers": {
"mandatory": ["right_command"],
"optional": ["any"]
}
},
"to": [
{
"key_code": "down_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "k",
"modifiers": {
"mandatory": ["right_command"],
"optional": ["any"]
}
},
"to": [
{
"key_code": "up_arrow"
}
],
"type": "basic"
},
{
"from": {
"key_code": "l",
"modifiers": {
"mandatory": ["right_command"],
"optional": ["any"]
}
},
"to": [
{
"key_code": "right_arrow"
}
],
"type": "basic"
}
]
}
]
}
@kxccc
Copy link
Author

kxccc commented Sep 16, 2023

karabiner://karabiner/assets/complex_modifications/import?url=json url

@kxccc
Copy link
Author

kxccc commented Jun 18, 2024

Simple Modifications

  • left_shift --> sticky left_shift
  • right_shift --> sticky right_control

@Jackiexiao
Copy link

Jackiexiao commented Jul 3, 2024

导入上面配置的方法,把下面的字符串复制到浏览器地址栏中打开

karabiner://karabiner/assets/complex_modifications/import?url=https://gist.githubusercontent.com/kxccc/f38351a59ae3ed3a56fa9dc018d9415e/raw/aaf98f6ae8fec95ec7b6b1a8df36ca000510cd7e/im-switch.json

然后就会有

image

@Jackiexiao
Copy link

ps: 如果只想设置 esc 切换英文输入法的话,用这个karabiner设置: https://gist.github.com/Jackiexiao/243468b2dbb8017af6a7baefb7af0ed2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment