KeyRemap4MacBook.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <?xml version="1.0"?>
  2. <root>
  3. <appdef>
  4. <appname>ITERM</appname>
  5. <equal>com.googlecode.iterm2</equal>
  6. </appdef>
  7. <!--
  8. KeyRemap4MacBook defines a list of apps to ignore when using any of the
  9. "Emacs Mode" key mappings. That list includes "TERMINAL" (as well as other
  10. apps).
  11. See: https://github.com/tekezo/KeyRemap4MacBook/blob/953717f78c/src/core/server/Resources/replacementdef.xml#L46
  12. By default "TERMINAL" includes Terminal.app *and* iTerm2. When we define
  13. "ITERM" above, it seems to remove iTerm2 from the definition of "TERMINAL".
  14. So, we need to redefine the list of "EMACS_MODE_IGNORE_APPS" to include
  15. all of the original apps *and* "ITERM".
  16. -->
  17. <!-- ============================================================ -->
  18. <replacementdef>
  19. <replacementname>EMACS_MODE_IGNORE_APPS</replacementname>
  20. <replacementvalue>
  21. EMACS,
  22. ITERM,
  23. TERMINAL,
  24. VI,
  25. VIRTUALMACHINE,
  26. X11
  27. </replacementvalue>
  28. </replacementdef>
  29. <vkopenurldef>
  30. <name>KeyCode::VK_OPEN_URL_APP_Chrome</name>
  31. <url>file:///Applications/Google%20Chrome.app</url>
  32. </vkopenurldef>
  33. <vkopenurldef>
  34. <name>KeyCode::VK_OPEN_URL_APP_iTerm</name>
  35. <url>file:///Applications/iTerm.app</url>
  36. </vkopenurldef>
  37. <vkopenurldef>
  38. <name>KeyCode::VK_OPEN_URL_APP_Rdio</name>
  39. <url>file:///Applications/Rdio.app</url>
  40. </vkopenurldef>
  41. <vkopenurldef>
  42. <name>KeyCode::VK_OPEN_URL_APP_Xcode</name>
  43. <url>file:///Applications/Xcode.app</url>
  44. </vkopenurldef>
  45. <vkopenurldef>
  46. <name>KeyCode::VK_OPEN_URL_APP_Charles</name>
  47. <url>file:///Applications/Charles.app</url>
  48. </vkopenurldef>
  49. <item>
  50. <name>Double-tap Left Shift for CapsLock</name>
  51. <identifier>com.jasonrudolph.double_lshift_to_caps</identifier>
  52. <autogen>__DoublePressModifier__ KeyCode::SHIFT_L, KeyCode::SHIFT_L, KeyCode::CAPSLOCK</autogen>
  53. </item>
  54. <item>
  55. <!--
  56. Inspired by and adapted from Steve Losh's "Modern Space Cadet" post:
  57. http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#hyper
  58. -->
  59. <name>Right Option to "Hyper"</name>
  60. <appendix>OS X doesn't have a native Hyper key. Let's define Hyper as Control+Shift+Option+Command.</appendix>
  61. <appendix>(This maps Right Option to our definition of Hyper.)</appendix>
  62. <identifier>com.jasonrudolph.right_option_hyper</identifier>
  63. <!--
  64. "ModifierFlag::OPTION_R | ModifierFlag::NONE" causes this remapping to
  65. fire *only* when the the right option key is used *without* any other
  66. modifiers.
  67. See http://pqrs.org/macosx/keyremap4macbook/xml-basic.html.en#modifierflag-none
  68. -->
  69. <autogen>
  70. __KeyToKey__
  71. KeyCode::OPTION_R, ModifierFlag::OPTION_R | ModifierFlag::NONE,
  72. KeyCode::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
  73. </autogen>
  74. <item>
  75. <name>Hyper+B to open Chrome ("B" for "Browser")</name>
  76. <identifier>com.jasonrudolph.hyper_b</identifier>
  77. <autogen>
  78. __KeyToKey__
  79. KeyCode::B, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,
  80. KeyCode::VK_OPEN_URL_APP_Chrome,
  81. </autogen>
  82. </item>
  83. <item>
  84. <name>Hyper+C to open Charles ("C" for "Charles")</name>
  85. <identifier>com.jasonrudolph.hyper_c</identifier>
  86. <autogen>
  87. __KeyToKey__
  88. KeyCode::C, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,
  89. KeyCode::VK_OPEN_URL_APP_Charles,
  90. </autogen>
  91. </item>
  92. <item>
  93. <name>Hyper+X to open Xcode ("X" for "XCode")</name>
  94. <identifier>com.jasonrudolph.hyper_x</identifier>
  95. <autogen>
  96. __KeyToKey__
  97. KeyCode::X, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,
  98. KeyCode::VK_OPEN_URL_APP_Xcode,
  99. </autogen>
  100. </item>
  101. <item>
  102. <name>Hyper+R to open Rdio ("R" for "Rdio")</name>
  103. <identifier>com.jasonrudolph.hyper_r</identifier>
  104. <autogen>
  105. __KeyToKey__
  106. KeyCode::R, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,
  107. KeyCode::VK_OPEN_URL_APP_Rdio,
  108. </autogen>
  109. </item>
  110. <item>
  111. <name>Hyper+T to open iTerm ("T" for "Terminal")</name>
  112. <identifier>com.jasonrudolph.hyper_t</identifier>
  113. <autogen>
  114. __KeyToKey__
  115. KeyCode::T, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,
  116. KeyCode::VK_OPEN_URL_APP_iTerm,
  117. </autogen>
  118. </item>
  119. </item>
  120. <item>
  121. <name>Option+H/L to delete previous/next word in iTerm 2 (and Terminal)</name>
  122. <identifier>com.jasonrudolph.terminal.option_with_h_or_l_to_delete_previous_word_or_next_word</identifier>
  123. <only>ITERM, TERMINAL</only>
  124. <!--
  125. "ModifierFlag::OPTION_L | ModifierFlag::NONE" causes this remapping to
  126. fire *only* when the the left option key is used *without* any other
  127. modifiers.
  128. See http://pqrs.org/macosx/keyremap4macbook/xml-basic.html.en#modifierflag-none
  129. -->
  130. <autogen>
  131. __KeyToKey__
  132. KeyCode::H, ModifierFlag::OPTION_L | ModifierFlag::NONE,
  133. KeyCode::W, ModifierFlag::CONTROL_L
  134. </autogen>
  135. <autogen>
  136. __KeyToKey__
  137. KeyCode::L, ModifierFlag::OPTION_L | ModifierFlag::NONE,
  138. KeyCode::ESCAPE,
  139. KeyCode::D
  140. </autogen>
  141. </item>
  142. <item>
  143. <name>Option+H/L to delete previous/next word</name>
  144. <identifier>com.jasonrudolph.option_with_h_or_l_to_delete_previous_word_or_next_word</identifier>
  145. <!--
  146. "ModifierFlag::OPTION_L | ModifierFlag::NONE" causes this remapping to
  147. fire *only* when the the left option key is used *without* any other
  148. modifiers.
  149. See http://pqrs.org/macosx/keyremap4macbook/xml-basic.html.en#modifierflag-none
  150. -->
  151. <autogen>
  152. __KeyToKey__
  153. KeyCode::H, ModifierFlag::OPTION_L | ModifierFlag::NONE,
  154. KeyCode::DELETE, ModifierFlag::OPTION_L
  155. </autogen>
  156. <autogen>
  157. __KeyToKey__
  158. KeyCode::L, ModifierFlag::OPTION_L | ModifierFlag::NONE,
  159. KeyCode::FORWARD_DELETE, ModifierFlag::OPTION_L
  160. </autogen>
  161. </item>
  162. <item>
  163. <name>Control+dash/pipe to split iTerm2 panes horizontally/vertically</name>
  164. <identifier>com.jasonrudolph.iterm.control_with_dash_or_pipe_to_split_pane</identifier>
  165. <only>ITERM</only>
  166. <autogen>
  167. __KeyToKey__
  168. KeyCode::MINUS, ModifierFlag::CONTROL_L,
  169. KeyCode::D, ModifierFlag::COMMAND_L | ModifierFlag::SHIFT_L
  170. </autogen>
  171. <autogen>
  172. __KeyToKey__
  173. KeyCode::BACKSLASH, ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L,
  174. KeyCode::D, ModifierFlag::COMMAND_L | ModifierFlag::NONE
  175. </autogen>
  176. </item>
  177. <!--
  178. Adapted from the built-in "Simultaneous Vi Mode" option:
  179. https://github.com/tekezo/KeyRemap4MacBook/blob/6aa99ba/src/core/server/Resources/include/checkbox/simultaneouskeypresses_vi_mode.xml#L4
  180. -->
  181. <item>
  182. <name>(S)uper (D)uper Mode</name>
  183. <item>
  184. <name>What's (S)uper (D)uper Mode?</name>
  185. <identifier vk_config="true">notsave.com.jasonrudolph.simultaneouskeypresses_vimode</identifier>
  186. <autogen>__ShowStatusMessage__ (S)uper (D)uper Mode</autogen>
  187. <appendix>To activate, push S and D keys simultaneously and hold them down.</appendix>
  188. <appendix>Now you're in (S)uper (D)uper mode. It's like a secret keyboard _inside_ your keyboard. (Whoa.)</appendix>
  189. <appendix>It's optimized for keeping you on the home row, or very close to it.</appendix>
  190. <appendix>---</appendix>
  191. <appendix>Now you can:</appendix>
  192. <appendix>- Use H/J/K/L for Left/Down/Up/Right</appendix>
  193. <appendix>- Use F for Command</appendix>
  194. <appendix>- Use A for Option (AKA Alt)</appendix>
  195. <appendix>- Use Space for Shift</appendix>
  196. <appendix>- Use M to copy</appendix>
  197. <appendix>- Use , to paste</appendix>
  198. <appendix>- Use MM to copy current line</appendix>
  199. <appendix>- Use A+J/K for Page Down/Up</appendix>
  200. <appendix>- Use I/O to move left/right between tabs</appendix>
  201. <appendix>- Use U/P to go to the first/last tab (in most apps)</appendix>
  202. <appendix>- Use A+H/L to move to previous/next word in all apps (including iTerm 2)</appendix>
  203. <autogen>__KeyToKey__ KeyCode::A, KeyCode::OPTION_L</autogen>
  204. <block>
  205. <only>ITERM, TERMINAL</only>
  206. <autogen>
  207. --KeyToKey--
  208. {{VI_H}}, VK_OPTION,
  209. KeyCode::ESCAPE,
  210. KeyCode::B
  211. </autogen>
  212. <autogen>
  213. --KeyToKey--
  214. {{VI_L}}, VK_OPTION,
  215. KeyCode::ESCAPE,
  216. KeyCode::F
  217. </autogen>
  218. </block>
  219. <autogen>
  220. __KeyToKey__
  221. {{VI_J}}, VK_OPTION,
  222. KeyCode::PAGEDOWN
  223. </autogen>
  224. <autogen>
  225. __KeyToKey__
  226. {{VI_K}}, VK_OPTION,
  227. KeyCode::PAGEUP
  228. </autogen>
  229. <autogen>__KeyToKey__ {{VI_H}}, KeyCode::CURSOR_LEFT</autogen>
  230. <autogen>__KeyToKey__ {{VI_J}}, KeyCode::CURSOR_DOWN</autogen>
  231. <autogen>__KeyToKey__ {{VI_K}}, KeyCode::CURSOR_UP</autogen>
  232. <autogen>__KeyToKey__ {{VI_L}}, KeyCode::CURSOR_RIGHT</autogen>
  233. <autogen>__KeyToKey__ KeyCode::F, KeyCode::COMMAND_L</autogen>
  234. <autogen>__KeyToKey__ KeyCode::SPACE, KeyCode::SHIFT_L</autogen>
  235. <block>
  236. <lastpressedphysicalkey_only>KeyCode::M</lastpressedphysicalkey_only>
  237. <elapsedtimesincelastpressed_lessthan>Millisecond::RawValue::200</elapsedtimesincelastpressed_lessthan>
  238. <autogen>
  239. __KeyToKey__
  240. KeyCode::M,
  241. KeyCode::CURSOR_LEFT, ModifierFlag::COMMAND_L,
  242. KeyCode::CURSOR_DOWN, ModifierFlag::SHIFT_L,
  243. KeyCode::C, ModifierFlag::COMMAND_L
  244. </autogen>
  245. </block>
  246. <autogen>
  247. __KeyToKey__
  248. KeyCode::M,
  249. KeyCode::C, ModifierFlag::COMMAND_L
  250. </autogen>
  251. <autogen>
  252. __KeyToKey__
  253. KeyCode::COMMA,
  254. KeyCode::V, ModifierFlag::COMMAND_L
  255. </autogen>
  256. <autogen>
  257. __KeyToKey__
  258. KeyCode::I,
  259. KeyCode::BRACKET_LEFT, ModifierFlag::COMMAND_L | ModifierFlag::SHIFT_L
  260. </autogen>
  261. <autogen>
  262. __KeyToKey__
  263. KeyCode::O,
  264. KeyCode::BRACKET_RIGHT, ModifierFlag::COMMAND_L | ModifierFlag::SHIFT_L
  265. </autogen>
  266. <autogen>
  267. __KeyToKey__
  268. KeyCode::U,
  269. KeyCode::KEY_1, ModifierFlag::COMMAND_L
  270. </autogen>
  271. <autogen>
  272. __KeyToKey__
  273. KeyCode::P,
  274. KeyCode::KEY_9, ModifierFlag::COMMAND_L
  275. </autogen>
  276. </item>
  277. <item>
  278. <name>Simultaneous Key Presses [S+D] turns on "(S)uper (D)uper mode"</name>
  279. <identifier>remap.com_jasonrudolph_simultaneouskeypresses_vimode_sd</identifier>
  280. <autogen>
  281. __SimultaneousKeyPresses__
  282. KeyCode::D, KeyCode::S,
  283. KeyCode::VK_CONFIG_SYNC_KEYDOWNUP_notsave_com_jasonrudolph_simultaneouskeypresses_vimode
  284. </autogen>
  285. </item>
  286. </item>
  287. </root>