Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Magic Keyboard Home and Ends keys to behave like Windows in macOS High Sierra?

I am a full-time .NET Developer, so I work in Windows 10 at work; however, I definitely prefer macOS and use it at home. I am a constant user of the Home and End keys and they make me so much more efficient. Is there any way to force the Home and End keys on macOS to behave like Windows 10?


What I Want

Home: Sends cursor to beginning of current line

End: Sends cursor to end of current line

Shift-Home: Sends cursor to beginning of current line with selection

Shift-End: Sends cursor to end of current line with selection

Command-Home: Sends cursor to beginning of current document

Command-End: Sends cursor to end of current document

Shift-Command-Home: Sends cursor to beginning of current document with selection

Shift-Command-End: Sends cursor to end of current document with selection


What I've Tried

A simple Google search provided me with the possible solution of adding custom NSResponder entries in ~/Library/KeyBindings/DefaultKeyBinding.dict and rebooting. Unfortunately, that does not seem to have worked. I have tested it in Xcode, Sublime Text, and Safari. The keys appear to behave in the normal macOS manner.

{
    "\UF729"  = "moveToBeginningOfLine:";
    "\UF72B"  = "moveToEndOfLine:";                        
    "$\UF729" = "moveToBeginningOfLineAndModifySelection:";
    "$\UF72B" = "moveToEndOfLineAndModifySelection:";
}

I have also tried using BetterTouchTool to set a keyboard shortcut mapping Home to Command-Left and End to Command-Right. That works for Home and End but it doesn't work for the selecting text nor for navigating the document


What I'm Using

  • Mid-2012 non-Retina MacBook Pro
  • macOS High Sierra Public Beta 5
  • Apple Magic Keyboard
  • Xcode, Sublime Text, Safari specifically

Bonus Points

Command-Left: Sends cursor to beginning of word

Command-Right: Sends cursor to end of word

Shift-Command-Left: Sends cursor to beginning of word with selection

Shift-Command-Right: Sends cursor to end of word with selection

like image 717
Nick Alexander Avatar asked Aug 11 '17 23:08

Nick Alexander


1 Answers

I'm not exactly sure what I changed, but it suddenly started to work. Here is my DefaultKeyBinding.dict. Here is a pastebin to the raw file.


{
"\UF729" = "moveToBeginningOfLine:";                            /* Home */
"\UF72B" = "moveToEndOfLine:";                                  /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";         /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:";               /* Shift + End */
"@\UF729" = "moveToBeginningOfDocument:";                       /* Cmd + Home */
"@\UF72B" = "moveToEndOfDocument:";                             /* Cmd + End */
"@$\UF729" = "moveToBeginningOfDocumentAndModifySelection:";    /* Shift + Cmd + Home */
"@$\UF72B" = "moveToEndOfDocumentAndModifySelection:";          /* Shift + Cmd + End */
"@\Uf702" = "moveWordLeft:";                                    /* Cmd + Left */
"@\Uf703" = "moveWordRight:";                                   /* Cmd + Right */
"@$\Uf702" = "moveWordLeftAndModifySelection:";                 /* Shift + Cmd + Left */
"@$\Uf703" = "moveWordRightAndModifySelection:";                /* Shift + Cmd + Right */
}
like image 89
Nick Alexander Avatar answered Oct 10 '22 21:10

Nick Alexander