mac 使用Karabiner配置键盘映射


声明:本文转载自https://my.oschina.net/huangweiindex/blog/1649219,转载目的在于传递更多信息,仅供学习交流之用。如有侵权行为,请联系我,我会及时删除。

配置完之后的效果:

command_left+space : 触发IDEA search everywhere

space+command_left:触发IDEA search everywhere

option_left+space:触发打开Google浏览器

space+option_left:触发打开Google浏览器

单独按下option_left:触发IDEA 查找接口

单独按下control_left:触发切换窗口

单独按下command_right:打开Alfred

单独按下caps lock:触发escape

 

private.xml 文件内容如下:

<?xml version="1.0"?> <root>     <item>         <!-- 单独按下相当于escape.和别的键组合按下, 相当于“⇧⌃⌥⌘” -->         <name>F19 to F19</name>         <appendix>(F19 to Hyper (ctrl+shift+cmd+opt相当于“⇧⌃⌥⌘”) + F19 Only, send escape)</appendix>         <identifier>private.f192f19_escape</identifier>         <autogen>             --KeyOverlaidModifier--             KeyCode::F19,             KeyCode::COMMAND_L,             ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,             KeyCode::ESCAPE         </autogen>     </item>     <!-- 单独按下右边的Option/Alt 相当于Home  -->     <item>         <name>OPTION_R to HOME</name>         <appendix>(OPTION_R Only, send HOME)</appendix>         <identifier>private.option_r2home</identifier>         <autogen>             --KeyOverlaidModifier--             KeyCode::OPTION_R,             KeyCode::OPTION_R,             KeyCode::HOME         </autogen>     </item>     <!-- press command_l only equals "command +B ",to refresh browser -->      <!-- press control_l  only equals "command +Tab ",to switch window -->     <item>         <name>COMMAND_L to COMMAND_L+B</name>         <appendix>(COMMAND_L Only, send COMMAND+B,refresh browser)</appendix>         <identifier>private.command_l_only2command_and_b</identifier>         <autogen>             --KeyOverlaidModifier--             KeyCode::CONTROL_L,             KeyCode::CONTROL_L,             KeyCode::TAB, ModifierFlag::COMMAND_L         </autogen>     </item>      <!-- 单独按下F13(即原 escape),打开浏览器调试  -->     <item>         <name>F13 to option_command+I</name>         <appendix>(F13 Only, send COMMAND+OPTION+B,debug browser)</appendix>         <identifier>private.f13_only2command_option_and_i</identifier>         <!--<autogen>             &#45;&#45;KeyOverlaidModifier&#45;&#45;             KeyCode::F13,             KeyCode::F13,             KeyCode::I, ModifierFlag::COMMAND_L|ModifierFlag::OPTION_L         </autogen>-->         <autogen>             <!-- 双击F13(escape 键),触发 escape(命令会加上sudo ), 单击触发浏览器调试 -->             __KeyToKey__              KeyCode::F13,             KeyCode::VK_NONE,              Option::KEYTOKEY_DELAYED_ACTION,             KeyCode::I, ModifierFlag::COMMAND_L|ModifierFlag::OPTION_L,              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::F13,             KeyCode::ESCAPE,             KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT, <!-- drop second return key event -->         </autogen>     </item>       <item>         <!-- 左边的command单独按下相当于command+`.用来光标回到句尾           (if no other modifiers pressed) -->         <name>COMMAND_L to COMMAND_L+`</name>         <appendix>(COMMAND_L Only, send TAB+COMMAND_L)</appendix>         <identifier>private.command_l2tab_command</identifier>         <autogen>             --KeyOverlaidModifier--             KeyCode::COMMAND_L, ModifierFlag::COMMAND_L | ModifierFlag::NONE,             KeyCode::COMMAND_L,             KeyCode::DANISH_LESS_THAN,ModifierFlag::COMMAND_L         </autogen>     </item>      <item>         <name>space twice to COMMAND_L+space</name>         <appendix>(space twice, send SPACE+COMMAND_L)</appendix>         <identifier>private.command_l_twice2space_command</identifier>         <!-- <autogen>              __KeyToKey__               KeyCode::SPACE,              KeyCode::VK_NONE,               Option::KEYTOKEY_DELAYED_ACTION,              KeyCode::SPACE,               Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::SPACE,               KeyCode::SPACE,ModifierFlag::COMMAND_L,              KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT, &lt;!&ndash; drop second return key event &ndash;&gt;                &lt;!&ndash; 复制 &ndash;&gt;              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::C,              KeyCode::C,ModifierFlag::COMMAND_L,              KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,               &lt;!&ndash; 粘贴 &ndash;&gt;              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::V,              KeyCode::V,ModifierFlag::COMMAND_L,              KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,               &lt;!&ndash; 粘贴 &ndash;&gt;              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::B,              KeyCode::V,ModifierFlag::COMMAND_L,              KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,                &lt;!&ndash; 删除/DELETE &ndash;&gt;              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::D,              KeyCode::DELETE,              KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,               &lt;!&ndash; 调起浏览器 &ndash;&gt;              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::OPTION_L,              KeyCode::SPACE, ModifierFlag::OPTION_L,              KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,               &lt;!&ndash; space+r: 刷新浏览器刷新浏览器 &ndash;&gt;              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::R,              KeyCode::B, ModifierFlag::COMMAND_L|ModifierFlag::CONTROL_L,              KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT,          </autogen>-->          <!-- <autogen>             __KeyToKey__             KeyCode::SPACE, KeyCode::VK_NONE,             Option::KEYTOKEY_BEFORE_KEYDOWN, {{ ENV_Select_the_previous_input_source_shortcut }}, KeyCode::CONTROL_L,             Option::KEYTOKEY_AFTER_KEYUP,    {{ ENV_Select_the_previous_input_source_shortcut }},         </autogen> -->         <!-- 单独按下space,就是space; 组合按下space,相当于按下command_left -->         <autogen>             __KeyOverlaidModifier__             KeyCode::SPACE, ModifierFlag::NONE,              <!--                 You need to put "KeyCode"s between @begin and @end                 when you want to specify multiple KeyCode.             -->             @begin             <!-- hold 'SPACE' ,即组合键 -->             KeyCode::COMMAND_R,             @end              @begin             <!-- release 'SPACE' -->             KeyCode::SPACE,             @end              Option::KEYTOKEY_AFTER_KEYUP,             KeyCode::VK_CONFIG_FORCE_OFF_notsave_samples_keyoverlaidmodifier_use_separator_1,             KeyCode::VK_CONFIG_FORCE_OFF_notsave_samples_keyoverlaidmodifier_use_separator_2,         </autogen>     </item>      <item>         <!-- 双击 j,触发 end -->         <name>double click j to end</name>         <appendix>(double_click_L , send end)</appendix>         <identifier>private.command_l2tab_command222</identifier>         <autogen>             __KeyToKey__              KeyCode::J,             KeyCode::VK_NONE,              Option::KEYTOKEY_DELAYED_ACTION,             KeyCode::J,              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::J,             KeyCode::END,             KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT, <!-- drop second return key event -->          </autogen>          <!-- 双击 H,触发 home -->         <autogen>             __KeyToKey__              KeyCode::H,             KeyCode::VK_NONE,              Option::KEYTOKEY_DELAYED_ACTION,             KeyCode::H,              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::H,             KeyCode::HOME,             KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT, <!-- drop second return key event -->          </autogen>          <!-- 双击 i,触发 Quick definition control ⌘⇧I -->         <!--<autogen>             __KeyToKey__              KeyCode::I,             KeyCode::VK_NONE,              Option::KEYTOKEY_DELAYED_ACTION,             KeyCode::I,              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::I,             KeyCode::I, ModifierFlag::COMMAND_L|ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,             KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT, &lt;!&ndash; drop second return key event &ndash;&gt;          </autogen>-->     </item>      <item>         <!-- 左边的Option/Alt,单独按下相当于 command+T,用于IDEA中通过接口路径搜索 ,          (if no other modifiers pressed) -->         <name>OPTION_L to PAGEUP</name>         <appendix>(OPTION_L Only, send PAGEUP)</appendix>         <identifier>private.option_l2pageup</identifier>         <autogen>             --KeyOverlaidModifier--             KeyCode::OPTION_L, ModifierFlag::OPTION_L | ModifierFlag::NONE,             KeyCode::OPTION_L,             KeyCode::T,ModifierFlag::COMMAND_L         </autogen>     </item>     <item>         <!--  右边的command,单独按下相当于F17,用于触发Alfred -->         <name>COMMAND_R to F17</name>         <appendix>(COMMAND_R Only, send F17)</appendix>         <identifier>private.command_r_only2f17</identifier>         <autogen>             --KeyOverlaidModifier--             KeyCode::COMMAND_R,             KeyCode::COMMAND_R,             KeyCode::F17         </autogen>          <!-- <appendix>Command+Volume Down to Space (if no other modifiers pressed)</appendix>          <autogen>              __KeyToKey__              KeyCode::COMMAND_L, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_COMMAND | ModifierFlag::NONE,              KeyCode::J,          </autogen>-->       </item>     <item>         <!--  先按下space,再按下command_left 触发IDEA search everywhere -->         <name>space+COMMAND_L to IDEA search everywhere</name>         <appendix>space+Command_L to Command_R+SPACE(IDEA search everywhere)</appendix>         <identifier>private.space_command_l_2command_l_space_IDEAsearch</identifier>         <autogen>__KeyToKey__             KeyCode::COMMAND_L, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_COMMAND,             KeyCode::SPACE, ModifierFlag::COMMAND_R         </autogen>          <!--  先按下space,再按下option_left 触发切换到浏览器 -->         <appendix>space+option_L to Option_R+SPACE(IDEA search everywhere)</appendix>         <autogen>__KeyToKey__             KeyCode::OPTION_L, MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_COMMAND,             KeyCode::SPACE, ModifierFlag::OPTION_L         </autogen>     </item>     <item>         <!--   -->         <name>Hyper J to Down</name>         <appendix>(Hyper-J to Down arrow)</appendix>         <identifier>private.hyper-j-down</identifier>         <autogen>             --KeyToKey--             KeyCode::J,             ModifierFlag::COMMAND_L | ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,             KeyCode::CURSOR_DOWN         </autogen>     </item>     <item>         <!--   -->         <name>Hyper K to Up</name>         <appendix>(Hyper-K to Up arrow)</appendix>         <identifier>private.hyper-K-up</identifier>         <autogen>             --KeyToKey--             KeyCode::K,             ModifierFlag::COMMAND_L | ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,             KeyCode::CURSOR_UP         </autogen>     </item>     <item>         <!--   -->         <name>Hyper H to Left</name>         <appendix>(Hyper-H to Left arrow)</appendix>         <identifier>private.hyper-h-left</identifier>         <autogen>             --KeyToKey--             KeyCode::H,             ModifierFlag::COMMAND_L | ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,             KeyCode::CURSOR_LEFT         </autogen>     </item>     <item>         <name>Hyper L to Right</name>         <appendix>(Hyper-L to Right arrow)</appendix>         <identifier>private.hyper-l-right</identifier>         <autogen>             --KeyToKey--             KeyCode::L,             ModifierFlag::COMMAND_L | ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,             KeyCode::CURSOR_RIGHT         </autogen>     </item>     <item>         <name>Hyper N to Beginning of Line</name>         <appendix>(Hyper-N to Beginning of Line)</appendix>         <identifier>private.hyper-n-beginning-of-line</identifier>         <autogen>             --KeyToKey--             KeyCode::N,             ModifierFlag::COMMAND_L | ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,             KeyCode::CURSOR_LEFT,             ModifierFlag::COMMAND_L         </autogen>     </item>     <item>         <name>Hyper ; to End of Line</name>         <appendix>(Hyper-; to End of Line)</appendix>         <identifier>private.hyper-;-end-of-line</identifier>         <autogen>             --KeyToKey--             KeyCode::SEMICOLON,             ModifierFlag::COMMAND_L | ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,             KeyCode::CURSOR_RIGHT,             ModifierFlag::COMMAND_L         </autogen>     </item>     <item>         <name>Hyper I to Top</name>         <appendix>(Hyper-I to Top)</appendix>         <identifier>private.hyper-i-top</identifier>         <autogen>             --KeyToKey--             KeyCode::I,             ModifierFlag::COMMAND_L | ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,             KeyCode::CURSOR_UP,             ModifierFlag::COMMAND_L         </autogen>     </item>     <item>         <name>Hyper M to Bottom</name>         <appendix>(Hyper-M to Bottom)</appendix>         <identifier>private.hyper-m-bottom</identifier>         <autogen>             --KeyToKey--             KeyCode::M,             ModifierFlag::COMMAND_L | ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,             KeyCode::CURSOR_DOWN,             ModifierFlag::COMMAND_L         </autogen>     </item>     <!--  caps lock+Space 出发大小写转化 -->     <item>         <name>Hyper + Space To Capslock</name>         <appendix>Hyper(cmd+ctrl+shift+opt)+space, send Capslock</appendix>         <identifier>private.hyperspace2Capslock</identifier>         <autogen>             --KeyToKey--             KeyCode::SPACE, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L | ModifierFlag::COMMAND_L,             KeyCode::CAPSLOCK         </autogen>     </item>    <!-- <item>         <name>Change Escape to Mission Control</name>         <identifier>private.escape_to_mission_control</identifier>         <autogen>             &#45;&#45;KeyToKey&#45;&#45;             KeyCode::ESCAPE,             KeyCode::CURSOR_UP, ModifierFlag::CONTROL_L         </autogen>     </item>-->     <!-- 右边的shift 映射成为 control+command+B, 在 IDEA 中触发编译  -->     <item>         <name>Change SHIFT_R Key to END</name>         <identifier>private.shift_r_to_end2</identifier>         <autogen>__KeyOverlaidModifier__ KeyCode::SHIFT_R,KeyCode::SHIFT_R,             KeyCode::B, ModifierFlag::COMMAND_L|ModifierFlag::CONTROL_L         </autogen>   </item>     <!-- 左边的shift单独按下 映射成为 space  -->     <!--<item>         <name>Change SHIFT_L Key to SPACE</name>         <identifier>private.shift_left_to_SPACE</identifier>         <autogen>__KeyOverlaidModifier__ KeyCode::SHIFT_L,             KeyCode::SHIFT_L,             KeyCode::SPACE         </autogen>     </item>-->     <!-- 左边的option 和回车 映射成为左边的option 和回车+ 左边的 command(多了一个command) ,用于切换浏览器 -->     <!--<item>         <name>Change option_left Key to option_left_and_command_left</name>         <identifier>private.option_left_to_samlla233_command_left</identifier>         <autogen>__KeyToKey__             KeyCode::SPACE, ModifierFlag::OPTION_L,             KeyCode::RETURN, ModifierFlag::OPTION_L| ModifierFlag::COMMAND_L         </autogen>     </item>-->      <!-- 把 command_right+enter 映射成为三个键: shift + command+enter ,用于 IDEA 补全行尾 -->     <item>         <name>Change command_enter Key to shift_command_enter</name>         <identifier>private.shift_command_enter22</identifier>         <autogen>__KeyToKey__             KeyCode::RETURN, ModifierFlag::COMMAND_R,             KeyCode::RETURN, ModifierFlag::SHIFT_L| ModifierFlag::COMMAND_R         </autogen>     </item>      <!-- 双击 F,触发宏: end(回到句尾)+分号+回车,不需要,因为打字如果很快,会受到影响 -->     <!--<item>         <name>Change command_enter Key to shift_command_enter</name>         <identifier>private.shift_command_enter2233</identifier>         <autogen>             __KeyToKey__              KeyCode::F,             KeyCode::VK_NONE,             Option::KEYTOKEY_DELAYED_ACTION,             KeyCode::F,              Option::KEYTOKEY_DELAYED_ACTION_CANCELED_BY, KeyCode::F,             KeyCode::E,ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L |             ModifierFlag::COMMAND_L,             KeyCode::VK_KEYTOKEY_DELAYED_ACTION_DROP_EVENT, &lt;!&ndash; drop second return key event &ndash;&gt;         </autogen>     </item>-->      <item>       <!-- F18用于触发 paste  -->     <name>Change Fn Key to F18</name>     <identifier>private.fn_to_f182</identifier>       <autogen>__KeyOverlaidModifier__ KeyCode::FN, KeyCode::FN,KeyCode::F18</autogen>   </item>      <item>         <name>Daniel Simultaneouskey Shortcuts</name>         <item>             <identifier>remap.daniel_simultaneouskeypresses_seq</identifier>             <name>Strick key order shortcuts</name>             <appendix>Street Fighter style</appendix>              <!-- &lt;!&ndash; DF &ndash;&gt;              <autogen>                  __SimultaneousKeyPresses__                  @begin                  KeyCode::D, KeyCode::F, KeyCode::J,                  @end                   @begin                  KeyCode::F18, ModifierFlag::COMMAND_L,                  Option::SIMULTANEOUSKEYPRESSES_STRICT_KEY_ORDER,                  @end              </autogen>              <autogen>                  __SimultaneousKeyPresses__                  @begin                  KeyCode::D, KeyCode::J, KeyCode::F,                  @end                   @begin                  KeyCode::F18, ModifierFlag::COMMAND_L,                  Option::SIMULTANEOUSKEYPRESSES_STRICT_KEY_ORDER,                  @end              </autogen>-->             <!-- 同时按下 D,F 两个字母,触发回车 -->             <autogen>                 __SimultaneousKeyPresses__                 KeyCode::D, KeyCode::F,                 KeyCode::RETURN             </autogen>             <!-- 同时按下F,J,触发 control+Tab, 切换 IDEA 中的页签 -->             <autogen>                 __SimultaneousKeyPresses__                 KeyCode::F, KeyCode::J,                 KeyCode::TAB,ModifierFlag::CONTROL_L             </autogen>             <!-- 同时按下 S,D, 触发两个动作:保存, build -->             <autogen>                 __SimultaneousKeyPresses__                 KeyCode::S, KeyCode::D,                 KeyCode::B,ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L |                 ModifierFlag::COMMAND_L             </autogen>             <!-- 宏: end(回到句尾)+分号+回车 -->             <autogen>                 __SimultaneousKeyPresses__                 KeyCode::J, KeyCode::K,                 KeyCode::E,ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L |                 ModifierFlag::COMMAND_L             </autogen>             <!-- IDEA 智能提示 -->             <autogen>                 __SimultaneousKeyPresses__                 KeyCode::S, KeyCode::F,                 KeyCode::SPACE, ModifierFlag::CONTROL_L             </autogen>         </item>     </item> </root>

 

 

本文发表于2018年03月22日 22:38
(c)注:本文转载自https://my.oschina.net/huangweiindex/blog/1649219,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如有侵权行为,请联系我们,我们会及时删除.

阅读 1973 讨论 0 喜欢 0

抢先体验

扫码体验
趣味小程序
文字表情生成器

闪念胶囊

你要过得好哇,这样我才能恨你啊,你要是过得不好,我都不知道该恨你还是拥抱你啊。

直抵黄龙府,与诸君痛饮尔。

那时陪伴我的人啊,你们如今在何方。

不出意外的话,我们再也不会见了,祝你前程似锦。

这世界真好,吃野东西也要留出这条命来看看

快捷链接
网站地图
提交友链
Copyright © 2016 - 2021 Cion.
All Rights Reserved.
京ICP备2021004668号-1