Skip to content

Instantly share code, notes, and snippets.

@jonatack jonatack/private.xml forked from carwin/private.xml
Created Dec 26, 2015

What would you like to do?
Programmer's Shift Keys: Remapping parens, brackets and braces for to because nerd.
<?xml version="1.0"?>
<name>Programmer's Shift Keys</name>
Author: Carwin Young (@carwin)
Last Updated: 2014.07.18
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/
- 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.
<name>Parentheses ()</name>
<!-- Credit for this Parens section goes to Steve Losh: -->
<appendix>Shifts, when pressed alone, type parentheses. When used with other keys they're normal shifts.</appendix>
<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.
<name>Brackets []</name>
<appendix>Remap Command+Shift to brackets.</appendix>
<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_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.
KeyCode::COMMAND_L, KeyCode::SHIFT_L,
KeyCode::COMMAND_R, KeyCode::SHIFT_R,
<name>Braces {}</name>
<appendix>Remap Option+Shift to braces.</appendix>
<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_L, KeyCode::BRACKET_LEFT, ModifierFlag::SHIFT_L</autogen>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.