Leveraging the power of the right-command key in OS X

Not too long ago I was singing the praises of creating hotkeys to switch
between apps
, a method I consider to be far superior to using CMD+TAB
and having to cycle through open apps. I mentioned taking things a step further
by utilizing the right-command (and/or right-option) key to reduce the number of
keystrokes to switch apps.

Recently I finally got around to doing it, and after a few days of fighting
against muscle memory, things have been glorious!

Since I had to use Karabiner to be able to utilize the right-hand
keys explicitly, I thought it would be a good idea to try to shorten my stack
and do everything with Karabiner instead of having Karabiner talking back to
Hammerspoon. Nothing against Hammerspoon, but since I am working towards speed,
I don’t want to be fighting with multiple abstraction layers.

For those that haven’t read the previous article, I created hotkeys to quickly
switch between my top 3 applications. Cmd + Ctrl + 1-3 would launch or focus
Terminal, Chrome or Slack (in that order). It worked, but my vision was to map
Right Cmd + 1-3 to simplify things.

Once simplified, I took it a step further and added some additional hotkeys that
leverage the right command button a bit more. Here’s a list of what I have going
on now:

  • Right Command launches Alfred instead of Command + Space
  • Right Command + HJKL to scroll around similar to how I move in vim
  • Right Command + 1-3 jumps to Terminal, Chrome and Slack respectively

It didn’t take much to pull off, in fact, here’s my private.xml file for
Karabiner:

<?xml version="1.0"?>
<root>
  <item>
    <name>Right Command => Launch Alfred</name>
    <identifier>rightCommand</identifier>
    <autogen>
      __KeyDownUpToKey__
      KeyCode::COMMAND_R,
      KeyCode::COMMAND_L, KeyCode::SPACE
    </autogen>
  </item>
  <item>
    <name>Right Command + H => Scroll Left</name>
    <identifier>rightCommandH</identifier>
    <autogen>
      __KeyDownUpToKey__
      KeyCode::H, ModifierFlag::COMMAND_R,
      KeyCode::VK_MOUSEKEY_FIXED_DISTANCE_SCROLL_LEFT
    </autogen>
  </item>
  <item>
    <name>Right Command + J => Scroll Down</name>
    <identifier>rightCommandJ</identifier>
    <autogen>
      __KeyDownUpToKey__
      KeyCode::J, ModifierFlag::COMMAND_R,
      KeyCode::VK_MOUSEKEY_FIXED_DISTANCE_SCROLL_DOWN
    </autogen>
  </item>
  <item>
    <name>Right Command + K => Scroll Up</name>
    <identifier>rightCommandK</identifier>
    <autogen>
      __KeyDownUpToKey__
      KeyCode::K, ModifierFlag::COMMAND_R,
      KeyCode::VK_MOUSEKEY_FIXED_DISTANCE_SCROLL_UP
    </autogen>
  </item>
  <item>
    <name>Right Command + L => Scroll Right</name>
    <identifier>rightCommandL</identifier>
    <autogen>
      __KeyDownUpToKey__
      KeyCode::L, ModifierFlag::COMMAND_R,
      KeyCode::VK_MOUSEKEY_FIXED_DISTANCE_SCROLL_RIGHT
    </autogen>
  </item>
  <vkopenurldef>
    <name>KeyCode::VK_OPEN_URL_APP_Terminal</name>
    <url type="file">/Applications/Utilities/Terminal.app</url>
  </vkopenurldef>
  <item>
    <name>Right Command + 1 => Launch or Focus Terminal</name>
    <identifier>rightCommand1</identifier>
    <autogen>
      --KeyToKey--
      KeyCode::1, ModifierFlag::COMMAND_R,
      KeyCode::VK_OPEN_URL_APP_Terminal
    </autogen>
  </item>
  <vkopenurldef>
    <name>KeyCode::VK_OPEN_URL_APP_Chrome</name>
    <url type="file">/Applications/Google Chrome.app</url>
  </vkopenurldef>
  <item>
    <name>Right Command + 2 => Launch or Focus Chrome</name>
    <identifier>rightCommand2</identifier>
    <autogen>
      --KeyToKey--
      KeyCode::2, ModifierFlag::COMMAND_R,
      KeyCode::VK_OPEN_URL_APP_Chrome
    </autogen>
  </item>
  <vkopenurldef>
    <name>KeyCode::VK_OPEN_URL_APP_Slack</name>
    <url type="file">/Applications/Slack.app</url>
  </vkopenurldef>
  <item>
    <name>Right Command + 3 => Launch or Focus Slack</name>
    <identifier>rightCommand3</identifier>
    <autogen>
      --KeyToKey--
      KeyCode::3, ModifierFlag::COMMAND_R,
      KeyCode::VK_OPEN_URL_APP_Slack
    </autogen>
  </item>
</root>

Still taking a bit of time to get used to, but the time saved is well worth it.
gou may consider saving one keystroke to be trivial, but when it’s related to
somethng I am doing hundreds of times a day, it definitely adds up.

My Karabiner configuration is subject to change at any time, but you can keep up
to date with the latest by starring my dotfiles out on GitHub!

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.


If you found this article helpful, please consider buying me a coffee.