melreusthe rectangle field manual

Reference

Keycodes and Modifier Values for Binding Hidden Commands

Binding a hidden command needs two numbers. This page is both tables, plus a way to check any key you cannot find here.

05 Jul 2026 · 5 min read · updated for current macOS

Terminal — zsh$ defaults write com.knollsoft.Rectangle topLeftNinth \$ -dict-add keyCode -float 18 modifierFlags -float 917504# ↑ the 1 key ↑ ctrl+option+shift$ killall Rectangle && open -a Rectangle# ctrl+option+shift+1 now snaps to the top-left ninth
The anatomy of a hidden binding: a command name, a keycode and a modifier sum.

Modifier values

Each modifier has an integer value. Combinations are the sum.

ModifierValue
Command1048576
Option524288
Control262144
Shift131072
Fn8388608
CombinationSumComment
Control + Option786432The scheme most defaults use
Control + Option + Shift917504The safest space for additions
Control + Option + Command1835008
Control + Option + Command + Shift1966080Nothing else on macOS uses this
Command + Option1572864Collides with browsers frequently
Control + Shift393216Good for deliberate bulk commands
Prefer Control+Option+Shift for anything you add

It is almost entirely unclaimed across macOS and application menus. Command-based combinations will collide with something, usually at the worst moment.

Letter keys

KeyCodeKeyCodeKeyCode
A0J38S1
B11K40T17
C8L37U32
D2M46V9
E14N45W13
F3O31X7
G5P35Y16
H4Q12Z6
I34R15

Numbers, punctuation and special keys

KeyCodeKeyCode
118029
219- (minus)27
320= (equals)24
421[33
523]30
622; (semicolon)41
726' (quote)39
828, (comma)43
925. (period)47
Return36/ (slash)44
Tab48\\ (backslash)42
Space49` (grave)50
Delete51Escape53
ArrowCode
Left123
Right124
Down125
Up126

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
If a binding does nothing

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.com

Questions

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.