Make Home & End keys behave like Windows on Mac OS X

I’ve been using Mac OS X daily since 2001 when I purchased my Titanium PowerBook and I still can’t get used the home and end key behavior.

If, like me, you want Home to send you to the start of the line and not to the top of the document then create a file called DefaultKeyBinding.dict in your ~/Library/KeyBindings folder (might need to create that folder too) with the following contents:

  "\UF729"  = moveToBeginningOfParagraph:; // home
  "\UF72B"  = moveToEndOfParagraph:; // end
  "$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home
  "$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end
  "^\UF729" = moveToBeginningOfDocument:; // ctrl-home
  "^\UF72B" = moveToEndOfDocument:; // ctrl-end
  "^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home
  "^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end

This remapping does the following in most Mac apps including Chrome (some apps do their own key handling):

  • Home and End will go to start and end of line
  • ShiftHome and ShiftEnd will select to start and end of line
  • CtrlHome and CtrlEnd will go to start and end of document
  • ShiftCtrlHome and ShiftCtrlEnd will select to start and end of document

Note that you will need to reboot after creating this file for it to take effect.

If you have a PC keyboard with LED back-lighting and would like the scroll-lock, num-lock or caps-lock LEDs on when using your Mac check out my free SetLEDs for Mac


13 responses

  1. Avatar for Alkirah

    Amazing! Works like a charm on latest el capitan version. Thanks!

    Alkirah – September 2nd, 2016
  2. Avatar for Alex

    For words selection like in Windows can be used next rules:

    ”^\UF702” = (moveWordLeft:); // ctrl-left “^$\UF702” = (moveWordLeftAndModifySelection:); // ctrl-shift-left “^\UF703” = (moveWordRight:); // ctrl-right “^$\UF703” = (moveWordRightAndModifySelection:); // ctrl-shift-right

    Alex – September 30th, 2016
  3. Avatar for Ryan

    This worked on the latest macOS as well. Thank you.

    Ryan – January 26th, 2017
  4. Avatar for Martin

    also works on Version Mac OS X 10.12.4 (16E195). Awesome thanks, I love it :-) Is there some more stuff how to use that? Would love if I can change all my favourite shortcuts in one place

    Martin – May 10th, 2017
  5. Avatar for Shay

    DefaultKeyBinding.dict is ignored by some applications like XCode and Firefox and in some views like in WebKit web inspectors. Also good luck mapping the function key, caps lock (read up on that- a large amount of people want that). I am a left-hand mouser and wanted cut/copy/paste functions with the right hand. Trouble is, you can’t map control+fn (for copy), nor shift+fn (for paste), which are the keys that map positionally on a PC keyboard (I’m talking for PC keyboards with 2 rows of three keys: Ins, Home, Pg UP / Del, End, Pg Down). Another issue is when you are like me, doing lots of Windoz in a VM (Oracle Virtualbox) and remote desktop (Microsoft Remote Desktop for MacOS). There you need to pass different keys so everything works. Same with terminal apps. Karabiner is the go-to tool for key remapping, but there are issues with Sierra (Karabiner-elements is the next thing, but still a work in progress. So, I built something that works in all contexts (ok, almost all) using Hammerspoon, a superb tool for automation on the Mac:

    Shay – November 8th, 2017
  6. Avatar for Ashton Cormallen

    You are using ^ to denote the Ctrl key but how do I denote the Cmd key?

    Ashton Cormallen – December 28th, 2017
  7. Avatar for andyrak

    You can denote the Cmd key with ⌘ (PLACE OF INTEREST SIGN, Unicode: U+2318, UTF-8: E2 8C 98). Hope that helps.

    andyrak – February 27th, 2018
  8. Avatar for Tyler

    It has been SO hard to accept the loss of functionality of the Home/End keys after moving to Mac full time. What a blessing your tip/snippet is! Thanks, Damien!


    Tyler – August 3rd, 2018
  9. Avatar for Eric

    Hey, thanks for this! However, I don’t see it working in some apps in Chrome. Any suggestions. - Eric

    Eric – August 7th, 2018
  10. Avatar for Roger Miller

    Yay! Working on MacOS High Sierra

    Roger Miller – August 16th, 2018
  11. Avatar for pale

    Would it be strange if I were to propose to you on the spot?

    I’ve been using PC and Linux since 1997, and just got a Mac to get into iOS development. You saved my efficiency.

    pale August 24th, 2018
  12. Avatar for Brian

    This didn’t work for me on Mojave. I had to use BeginningOfLine instead of BeginningOfParagraph. Here is my file:

    { "\UF729" = moveToBeginningOfLine:; // home "\UF72B" = moveToEndOfLine:; // end "$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift-home "$\UF72B" = moveToEndOfLineAndModifySelection:; // shift-end "^\UF729" = moveToBeginningOfDocument:; // ctrl-home "^\UF72B" = moveToEndOfDocument:; // ctrl-end "^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home "^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end }

    Brian – March 21st, 2019
  13. Avatar for Jerry Baker

    Nice, works like a charm for High Sierra. By the way, restarting computer isn’t necessary. Restarting finder should be sufficient

    command: killall Finder


    Jerry Baker April 29th, 2019