Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
My DefaultKeyBinding.dict for Mac OS X
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers
^ : Ctrl
$ : Shift
~ : Option (Alt)
@ : Command (Apple)
# : Numeric Keypad
Non-Printable Key Codes
Standard
Up Arrow: \UF700 Backspace: \U0008 F1: \UF704
Down Arrow: \UF701 Tab: \U0009 F2: \UF705
Left Arrow: \UF702 Escape: \U001B F3: \UF706
Right Arrow: \UF703 Enter: \U000A ...
Insert: \UF727 Page Up: \UF72C
Delete: \UF728 Page Down: \UF72D
Home: \UF729 Print Screen: \UF72E
End: \UF72B Scroll Lock: \UF72F
Break: \UF732 Pause: \UF730
SysReq: \UF731 Menu: \UF735
Help: \UF746
OS X
delete: \U007F
For a good reference see http://osxnotes.net/keybindings.html.
NOTE: typically the Windows 'Insert' key is mapped to what Macs call 'Help'.
Regular Mac keyboards don't even have the Insert key, but provide 'Fn' instead,
which is completely different.
*/
{
"@\UF72B" = "moveToEndOfDocument:"; /* Cmd + End */
"~@\UF703" = "moveToEndOfDocument:"; /* Cmd + Option + Right Arrow */
"@$\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Cmd + End */
"@\UF729" = "moveToBeginningOfDocument:"; /* Cmd + Home */
"~@\UF702" = "moveToBeginningOfDocument:"; /* Cmd + Option + Left Arrow */
"@$\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Cmd + Home */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"~\UF702" = "moveToBeginningOfLine:"; /* Option + Left Arrow */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$~\UF702" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Option + Right Arrow */
"\UF72B" = "moveToEndOfLine:"; /* End */
"~\UF703" = "moveToEndOfLine:"; /* Option + Right Arrow */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
"$~\UF703" = "moveToEndOfLineAndModifySelection:"; /* Shift + Option + Left Arrow */
"\UF72C" = "pageUp:"; /* PageUp */
"\UF72D" = "pageDown:"; /* PageDown */
"$\UF728" = "cut:"; /* Shift + Del */
"$\UF727" = "paste:"; /* Shift + Ins */
"@\UF727" = "copy:"; /* Cmd + Ins */
"$\UF746" = "paste:"; /* Shift + Help */
"@\UF746" = "copy:"; /* Cmd + Help (Ins) */
"~j" = "moveBackward:"; /* Option + j */
"~l" = "moveForward:"; /* Option + l */
"~i" = "moveUp:"; /* Option + i */
"~k" = "moveDown:"; /* Option + k */
"@~i" = ("moveUp:","moveUp:","moveUp:","moveUp:","moveUp:","moveUp:","moveUp:","moveUp:",); /* Cmd + Option + j */
"@~k" = ("moveDown:","moveDown:","moveDown:","moveDown:","moveDown:","moveDown:","moveDown:","moveDown:",); /* Cmd + Option + j */
"@\UF702" = "moveWordBackward:"; /* Cmd + LeftArrow */
"@~j" = "moveWordBackward:"; /* Cmd + Option + j */
"@\U007F" = "deleteWordBackward:"; /* Cmd + Backspace */
"@\UF703" = "moveWordForward:"; /* Cmd + RightArrow */
"@~l" = "moveWordForward:"; /* Cmd + Option + l */
"@\UF728" = "deleteWordForward:"; /* Cmd + Delete */
"@$\UF702" = "moveWordBackwardAndModifySelection:"; /* Shift + Cmd + Leftarrow */
"@$\UF703" = "moveWordForwardAndModifySelection:"; /* Shift + Cmd + Rightarrow */
}
@ficus

This comment has been minimized.

Copy link

ficus commented Oct 26, 2016

Nice mappings. I'm having no luck getting this to work on Sierra. Have you been able to get it to work?

@mavichow

This comment has been minimized.

Copy link

mavichow commented Nov 29, 2016

no luck geting this to work on Sierra +1

@alexhayes

This comment has been minimized.

Copy link

alexhayes commented Dec 14, 2016

Likewise, doesn't seem to work on Sierra.

@alexhayes

This comment has been minimized.

Copy link

alexhayes commented Dec 14, 2016

While it's probably not the solution folks are looking for I ended up doing this in Keyboard Maestro.

@unboxedsolutions

This comment has been minimized.

Copy link

unboxedsolutions commented Dec 22, 2016

Keyboard Maestro was a great suggestion, it is working well for me. I miss Karabiner but this will do for now

@ggriffin

This comment has been minimized.

Copy link

ggriffin commented Jul 26, 2017

Using ~/Library/KeyBindings/DefaultKeyBinding.Dict to remap key bindings works for me under Sierra (10.12.5). Restarting a given app is required for the changes to take effect.

@ataiya

This comment has been minimized.

Copy link

ataiya commented Mar 21, 2018

@ggriffin have you tested this in HighSierra as well?

@agnz

This comment has been minimized.

Copy link

agnz commented Mar 28, 2018

I can confirm - works on HighSierra.

@thu-san

This comment has been minimized.

Copy link

thu-san commented Apr 30, 2018

Working on HighSierra on mine too

@mayqueen91

This comment has been minimized.

Copy link

mayqueen91 commented Jun 25, 2018

works well for HighSierra! I was a bit confused that I need to create directory KeyBindings by myself, but it worked! And now I can use both cmd+c and ctrl+c. This is great, previously "Copy link" buttons didn't work for me and now they do! THANK YOU.

@andrewdbate

This comment has been minimized.

Copy link

andrewdbate commented Jul 12, 2018

Also working on High Sierra for me -- thanks!! I prefer using these mappings over Karabiner elements because Karabiner elements screws with VMware Fusion and this does not.

@manolodeinternet

This comment has been minimized.

Copy link

manolodeinternet commented Aug 26, 2018

Beautiful presentation of the code !!!

Have any of you had any problems for overload any shortcut with any application (for changing the system default keybindings) ?

Thanks !!!

@fredrikaverpil

This comment has been minimized.

Copy link

fredrikaverpil commented Jan 20, 2019

This is what did (macOS Mojave):

{
    "~[" = (insertText:, "å");
    "~{" = (insertText:, "Å");
    "~'" = (insertText:, "ä");
    "~\"" = (insertText:, "Ä");
    "~;" = (insertText:, "ö");
    "~:" = (insertText:, "Ö");
}
@aserrallerios

This comment has been minimized.

Copy link

aserrallerios commented Apr 9, 2019

Where can I find the full reference of actions, like "moveToBeginningOfLineAndModifySelection"?

Thanks!

@phcamargo23

This comment has been minimized.

@phcamargo23

This comment has been minimized.

Copy link

phcamargo23 commented Apr 23, 2019

Following the suggestion of the author, switching Command by Control is a good one, however, to switch between applications and between guides got boring. Has anyone managed to solve this?

@Ogglord

This comment has been minimized.

Copy link

Ogglord commented May 20, 2019

Works great in Mojave 10.14.5 - lifesaver :)

@franksands

This comment has been minimized.

Copy link

franksands commented May 21, 2019

Not working for me :( I'm on Mojave 10.14.5 with a Microsoft Designer Keyboard and Brazilian layout (ABNT2)

@Ogglord

This comment has been minimized.

Copy link

Ogglord commented May 22, 2019

Not working for me :( I'm on Mojave 10.14.5 with a Microsoft Designer Keyboard and Brazilian layout (ABNT2)

Did you follow the instructions properly? Go to Library folder in your home folder, not the library folder in the root. Create the folder KeyBindings and the file "DefaultKeyBinding.Dict", case sensitive. Then it should work. I have a Func Mechanical KB with Swedish layout (Pro)

@franksands

This comment has been minimized.

Copy link

franksands commented May 22, 2019

Did you follow the instructions properly? Go to Library folder in your home folder, not the library folder in the root. Create the folder KeyBindings and the file "DefaultKeyBinding.Dict", case sensitive. Then it should work. I have a Func Mechanical KB with Swedish layout (Pro)

I indeed had copied to the Library folder in the root. It did work now! Thanks

@Walternate1

This comment has been minimized.

Copy link

Walternate1 commented Jun 3, 2019

10.14.5 (18F132) - Home/End to the beginning/end of the line is not working for me using the Mac base mail compose window, TextEdit, or in this message box. Does this work for you all in these situations?

@ryukoposting

This comment has been minimized.

Copy link

ryukoposting commented Jun 13, 2019

Hint for people having problems: there are some unicode quotes mixed in with the ASCII quotes in the gist! I'm not sure if that's what fixed it for me, but I did replace the unicode quotes with ASCII quotes (among other things):

{
//  "^c"       = "copy:"; // ctrl-c
//  "^v"       = "paste:"; // ctrl-v
//  "^x"       = "cut:"; // ctrl-x
//  "^z"       = "undo:"; // ctrl-z
//  "^y"       = "redo:"; // ctrl-y
//  "^a"       = "selectAll:"; // ctrl-a
//  "^s"       = "saveDocument:"; // ctrl-s
//  "^$s"      = "saveDocumentAs:"; // ctrl-shift-s
//  "^n"       = "newDocument:"; // ctrl-n
//  "^o"       = "openDocument:"; // ctrl-o
//  "^p"       = "printDocument:"; // ctrl-p
  "\UF729"   = "moveToBeginningOfParagraph:"; // home
  "\UF72B"   = "moveToEndOfParagraph:"; // end
  "$\UF729"  = "moveToBeginningOfParagraphAndModifySelection:"; // shift-home
  "$\UF72B"  = "moveToEndOfParagraphAndModifySelection:"; // shift-end
  "^\UF729"  = "moveToBeginningOfDocument:"; // ctrl-home
  "^\UF72B"  = "moveToEndOfDocument:"; // ctrl-end
  "^\UF702"  = "moveWordLeft:"; // ctrl-left
  "^\UF703"  = "moveWordRight:"; // ctrl-right
  "^$\UF702" = "moveWordLeftAndModifySelection:"; // ctrl-shift-left
  "^$\UF703" = "moveWordRightAndModifySelection:"; // ctrl-shift-right
  "^$\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; // ctrl-shift-home
  "^$\UF72B" = "moveToEndOfDocumentAndModifySelection:"; // ctrl-shift-end
}
@elevenfive

This comment has been minimized.

Copy link

elevenfive commented Sep 4, 2019

Truly, from the bottom of my heart, THANK YOU for sharing this. In concert with a fix for home/end in terminal, I can feel my once incredible pain when forced to use Mac OS slowly melting away.

@Rodrirokr

This comment has been minimized.

Copy link

Rodrirokr commented Sep 19, 2019

Working in Catalina (10.15 Beta) with no problem.

@raphaelsantos

This comment has been minimized.

Copy link

raphaelsantos commented Oct 6, 2019

Exactly what I was looking for, can't wait to test it. Thanks for sharing this.

@nicovs

This comment has been minimized.

Copy link

nicovs commented Oct 11, 2019

awesome!
Typing an IP on a keyboard with numpad was never this easy (since i switched from Windows to Mac :p)

{
   "#," = ("insertText:", ".");
}
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.