Skip to content

Instantly share code, notes, and snippets.

@cobalamin
Forked from carwin/private.xml
Last active August 29, 2015 14:15
Show Gist options
  • Save cobalamin/d07db52a7c0fed61231c to your computer and use it in GitHub Desktop.
Save cobalamin/d07db52a7c0fed61231c to your computer and use it in GitHub Desktop.
Programmer's Shift Keys: Remapping shift keys + modifiers to parens, brackets and braces.
<?xml version="1.0"?>
<root>
<item>
<name>Programmer's Shift Keys</name>
<!--
Author: Carwin Young (@carwin)
Edited by Simon Welker (@chipf0rk)
Last Updated: 2015-02-18
v.1.2
Programmer's Shift Keys
A private.xml for Karabiner (formerly KeyRemap4MacBook)
This private.xml file can be either chopped up for copy-pasting, or
used alone and modified if you don't already have your own file.
If you want to use it, add this file to
~/Library/Application\ Support/KeyRemap4MacBook/
Options:
- Parens: Maps individual strokes of the Shift keys to their
respective parenthesis keys.
- Brackets: Pairs Command and Shift keys to produce brackets.
- Braces: Pairs Option and Shift keys to produce braces.
</-->
<item>
<name>Parentheses ()</name>
<!-- Credit for this Parens section goes to Steve Losh: http://stevelosh.com/blog/2012/10/a-modern-space-cadet/ -->
<appendix>Shifts, when pressed alone, type parentheses. When used with other keys they're normal shifts.</appendix>
<identifier>private.shifts_to_parens</identifier>
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::NONE, KeyCode::SHIFT_R, KeyCode::KEY_0, ModifierFlag::SHIFT_L</autogen>
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_L, ModifierFlag::SHIFT_L | ModifierFlag::NONE, KeyCode::SHIFT_L, KeyCode::KEY_9, ModifierFlag::SHIFT_R</autogen>
<!--
Remap the "rolls" of () and )( because it's too easy to hit one
before finishing the other, and there's no other reason to be
pressing both shift keys at once anyway
-->
<autogen>--KeyToKey-- KeyCode::SHIFT_L, ModifierFlag::SHIFT_R, KeyCode::KEY_0, ModifierFlag::SHIFT_L, KeyCode::KEY_9, ModifierFlag::SHIFT_L</autogen>
<autogen>--KeyToKey-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_L, KeyCode::KEY_9, ModifierFlag::SHIFT_L, KeyCode::KEY_0, ModifierFlag::SHIFT_L</autogen>
<!--
Remap Rshift+Space to ') ', because when typing an end paren and
then a space I tend to hit space before I let go of rshift.
-->
<autogen>--KeyToKey-- KeyCode::SPACE, ModifierFlag::SHIFT_R, KeyCode::KEY_0, ModifierFlag::SHIFT_L, KeyCode::SPACE</autogen>
<!--
Steve also suggests setting the Key Overlaid Modifier Timeout
setting to a much lower value. I use 200ms.
-->
</item>
<item>
<name>Brackets []</name>
<appendix>Remap Command+Shift to brackets.</appendix>
<identifier>private.shifts_to_brackets</identifier>
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::COMMAND_R, KeyCode::BRACKET_RIGHT, ModifierFlag::NONE</autogen>
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_L, ModifierFlag::SHIFT_L | ModifierFlag::COMMAND_R, KeyCode::BRACKET_LEFT, ModifierFlag::NONE</autogen>
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::COMMAND_L, KeyCode::BRACKET_RIGHT, ModifierFlag::NONE</autogen>
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_L, ModifierFlag::SHIFT_L | ModifierFlag::COMMAND_L, KeyCode::BRACKET_LEFT, ModifierFlag::NONE</autogen>
<!--
Another way to do this that I like a lot is to actually map the
brackets to a SIMULTANEOUS keypress of SHIFT + COMMAND.
<autogen>
__SimultaneousKeyPresses__
KeyCode::COMMAND_L, KeyCode::SHIFT_L,
KeyCode::BRACKET_LEFT,
Option::SIMULTANEOUSKEYPRESSES_STRICT_KEY_ORDER
</autogen>
<autogen>
__SimultaneousKeyPresses__
KeyCode::COMMAND_R, KeyCode::SHIFT_R,
KeyCode::BRACKET_RIGHT,
Option::SIMULTANEOUSKEYPRESSES_STRICT_KEY_ORDER
</autogen>
-->
</item>
<item>
<name>Braces {}</name>
<appendix>Remap Option+Shift to braces.</appendix>
<identifier>private.shifts_to_braces</identifier>
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::OPTION_R, KeyCode::BRACKET_RIGHT, ModifierFlag::SHIFT_R</autogen>
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_L, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_R, KeyCode::BRACKET_LEFT, ModifierFlag::SHIFT_L</autogen>
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::OPTION_L, KeyCode::BRACKET_RIGHT, ModifierFlag::SHIFT_R</autogen>
<autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_L, ModifierFlag::SHIFT_L | ModifierFlag::OPTION_L, KeyCode::BRACKET_LEFT, ModifierFlag::SHIFT_L</autogen>
</item>
</item>
</root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment