Contents
Modifier values
Each modifier has an integer value. Combinations are the sum.
| Modifier | Value |
|---|---|
| Command | 1048576 |
| Option | 524288 |
| Control | 262144 |
| Shift | 131072 |
| Fn | 8388608 |
| Combination | Sum | Comment |
|---|---|---|
| Control + Option | 786432 | The scheme most defaults use |
| Control + Option + Shift | 917504 | The safest space for additions |
| Control + Option + Command | 1835008 | |
| Control + Option + Command + Shift | 1966080 | Nothing else on macOS uses this |
| Command + Option | 1572864 | Collides with browsers frequently |
| Control + Shift | 393216 | Good for deliberate bulk commands |
It is almost entirely unclaimed across macOS and application menus. Command-based combinations will collide with something, usually at the worst moment.
Letter keys
| Key | Code | Key | Code | Key | Code |
|---|---|---|---|---|---|
| A | 0 | J | 38 | S | 1 |
| B | 11 | K | 40 | T | 17 |
| C | 8 | L | 37 | U | 32 |
| D | 2 | M | 46 | V | 9 |
| E | 14 | N | 45 | W | 13 |
| F | 3 | O | 31 | X | 7 |
| G | 5 | P | 35 | Y | 16 |
| H | 4 | Q | 12 | Z | 6 |
| I | 34 | R | 15 | — | — |
Numbers, punctuation and special keys
| Key | Code | Key | Code |
|---|---|---|---|
| 1 | 18 | 0 | 29 |
| 2 | 19 | - (minus) | 27 |
| 3 | 20 | = (equals) | 24 |
| 4 | 21 | [ | 33 |
| 5 | 23 | ] | 30 |
| 6 | 22 | ; (semicolon) | 41 |
| 7 | 26 | ' (quote) | 39 |
| 8 | 28 | , (comma) | 43 |
| 9 | 25 | . (period) | 47 |
| Return | 36 | / (slash) | 44 |
| Tab | 48 | \\ (backslash) | 42 |
| Space | 49 | ` (grave) | 50 |
| Delete | 51 | Escape | 53 |
| Arrow | Code |
|---|---|
| Left | 123 |
| Right | 124 |
| Down | 125 |
| Up | 126 |
Finding a key that is not listed
Function keys, numeric keypad keys and anything on a non-US layout are easiest to identify by pressing them in a utility that reports the code. Free keycode viewers exist on the App Store and are the approach the official documentation recommends.
Alternatively, bind the key you want through the settings window to any ordinary command, then read back what was stored:
# bind the key via the interface first, then:
defaults read com.knollsoft.Rectangle leftHalf
# output shows the keyCode and modifierFlags actually recorded
{
keyCode = 123;
modifierFlags = 786432;
}
This is the most reliable method, because it reports exactly what your keyboard layout produces rather than what a table says it should.
Putting it together
D=com.knollsoft.Rectangle
# ctrl+opt+shift+1 → top-left ninth
defaults write $D topLeftNinth -dict-add keyCode -float 18 modifierFlags -float 917504
# ctrl+opt+shift+right → double width rightward
defaults write $D doubleWidthRight -dict-add keyCode -float 124 modifierFlags -float 917504
# ctrl+opt+] and ctrl+opt+[ → width only, larger and smaller
defaults write $D largerWidth -dict-add keyCode -float 30 modifierFlags -float 786432
defaults write $D smallerWidth -dict-add keyCode -float 33 modifierFlags -float 786432
# ctrl+shift+1 → tile the frontmost app's windows
defaults write $D tileActiveApp -dict-add keyCode -float 18 modifierFlags -float 393216
killall Rectangle && open -a Rectangle
Check four things in order: did you restart the app; is the modifier sum arithmetically correct; is the combination already claimed by something else; and is the command name spelled exactly as documented — they are case-sensitive and a typo fails silently.
To remove a binding you added, delete the key entirely rather than writing an empty value:
defaults delete com.knollsoft.Rectangle topLeftNinth
Get the current build
Rectangle is free and open source. Everything documented here works in the standard build.
Download from rectangleapp.comQuestions
Are keycodes layout-dependent?
The codes are physical positions, so a key in the same place produces the same code regardless of layout — but the character printed on it may differ.
Can I use function keys?
Yes, if you know the code. A keycode viewer is the quickest way to find it.
Why did my binding fail silently?
Most often a missing restart, an incorrect modifier sum, or a misspelled command name.
How do I remove a custom binding?
defaults delete with the command name. Writing an empty value is not the same thing.