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. I still can’t get used the Home and End key behaviour.

Partial shot of an Apple Mac keyboard showing the Home & End keys

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 manage their key handling directly):

  • 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 need to reboot after creating this file for it to take effect. Also make sure your editor does not append TXT to the end of it!

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

[)amien

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

  1. Avatar for

    Information is only used to show your comment. See my Privacy Policy.

  2. Avatar for ngupta

    For me the following config does not work on Sequoia for Home/End key => beginning/end of line:

    {
    /* Remap Home / End keys to be correct */
    "\UF729" = "moveToBeginningOfLine:"; /* Home */
    "\UF72B" = "moveToEndOfLine:"; /* End */
    "$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
    "$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
    "^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */
    "^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */
    "$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */
    "$^\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */
    }
    

    Anyone else having this issue on Sequoia. IIRC it worked fine on macos version before this one.

  3. Avatar for edhalsim
    edhalsim

    Anyone get this to work with Microsoft’s OneNote on MacBook Pro? Is there a separate solution for that app.?

  4. Avatar for cyberschlumpf
    cyberschlumpf

    MBP 16″ of 2023 on Sonoma 14.3. Can’t get it to work. Basically tried all variations: With/Without Reboot, killall Finder, etc. “Line” instead of “Paragraph” — the behavior is always the same. Home/End key do not jump to beginning/end of line. Some examples show a double “” some use a single “". Some write the file with a capital Dict, some lowercase.

    My latest attempt:

    cat ~/Library/KeyBindings/DefaultKeyBinding.dict
    {
      "\\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
    }
    

    Tried 010 Editor and BBEdit — both show the normal behavior to just jump to the begin/end of the document and not the start/end of the current line.

    Anyone here who can definitely say it works for him on Sonoma? (And how his file looks like)

    Thanks!

  5. Avatar for haribol
    haribol

    Glad to know I’m not the only one who gets really tripped up by the home/end behavior on Mac … : ) Yes, this is very valuable.

    For all those who don’t know, in case it’s helpful, Cmd+Left Arrow and Cmd+Right Arrow natively do the same function on Mac, in almost all contexts … so if you are without a full keyboard, that can help.

    I once had a job working (as a programmer) in an environment of all Macs, after not using Mac much at all for many years, and that was the one huge thing I remember being frustrated by … my coworkers seemed to think I was nuts. But now I know it’s not just me!!

    I prefer using Mac these days, but when I am, I still prefer having Home/End go to beginning/end of line … it’s still easier than Cmd+Left/Right, and muscle memory still has it ingrained. (In order to hit Cmd+Left/Right, you still have to move your right hand over to the arrow keys anyway, which are right under Home and End, at least on most keyboards)

    Thanks again. I used Karabiner and another program for a long time to do this, but it’s nicer to know how to do it without installing any other dependencies, and especially for on computers where I may not be allowed to install helper programs to do such things.

  6. Avatar for Anders Thor
    Anders Thor

    Worked like a charm. MBP 13-inch, 2017, Ventura

  7. Avatar for Ale

    Thanks a lot, guys. On Mac Ventura latest OS It works as advertised. By the way, does anybody know how to use or program F13 through F19 on the Magic Keyboard?

  8. Avatar for ktbos

    Here’s my DefaultKeyBinding.dict that I put together with the various comments above. Includes both beginning/end of line and beginning/end of paragraph as well as beginning/end of document and beginning/end of word plus the change selection versions. Works well for me on Catalina. killall Finder does work though you also need to quit any application you want to be affected by it.

    {
    /* Home Button*/
    "\UF729" = moveToBeginningOfLine:;
    
    /* End Button */
    "\UF72B" = moveToEndOfLine:;
    
    /* Shift + Home Button */
    "$\UF729" = moveToBeginningOfLineAndModifySelection:;
    
    /* Shift + End Button */
    "$\UF72B" = moveToEndOfLineAndModifySelection:;
    
    /* Ctrl + Home Button */
    "^\UF729" = moveToBeginningOfDocument:;
    
    /* Ctrl + End Button */
    "^\UF72B" = moveToEndOfDocument:;
    
    /* Shift + Ctrl + Home Button */
    "$^\UF729" = moveToBeginningOfDocumentAndModifySelection:;
    
    /* Shift + Ctrl + End Button*/
    "$^\UF72B" = moveToEndOfDocumentAndModifySelection:;
    
    /* Command + Home Button*/
    "@\UF729" = moveToBeginningOfParagraph:;
    
    /* Command + End Button */
    "@\UF72B" = moveToEndOfParagraph:;
    
    /* Command + Shift + Home Button */
    "@$\UF729" = moveToBeginningOfParagraphAndModifySelection:;
    
    /* Command + Shift + End Button */
    "@$\UF72B" = moveToEndOfParagraphAndModifySelection:;
    }
    
  9. Avatar for Yandiro
    Yandiro

    Can anyone get this working on Ventura 13.2?

  10. Avatar for John Doe
    John Doe

    Working successfully on macOS Ventura 13.1. Many thanks!

  11. Avatar for A J

    This is just a thank you to [)amien and all followup commenters — this is still useful and working information in Nov 2022 on MacOS Ventura :-)

  12. Avatar for imercuryous
    imercuryous

    Life saver indeed! Works on Ventura also!

  13. Avatar for info

    Keeps working like a charm in Monterey 12.4. thanks a lot, Damien!

  14. Avatar for Andrew P
    Andrew P

    Just brilliant — accidentally hitting to End key and jumping to the end of the doc when using a MS style keyboard plugged into my mac was pretty annoying.. This worked a dream.

  15. Avatar for Razcads
    Razcads

    Man you are such a life saver. It’s so irritating how MacOS has HOME and END keys mapped. Ridiculous. Apple is always ‘my way or highway, u be damned’ attitude. But thankfully we have samaritans like you who save the day and make us live another day!! Thankyou again.. May you get everything you wish in life! :)

  16. Avatar for Sam Schurter
    Sam Schurter

    Big Sur 11.6 on a M1 Macbook Pro and the code in the article is still working 👌

  17. Avatar for j. g.

    Since vcode does not support this file, here’s what I’ve put to my keybindings.json in vscode to make the muscle memory work in vscode too (note: I bound all shortcuts to both ctrl-… and cmd-… just to make my life easier; and I had to unbind some MacOS-specific vscode default keybindings).

      {
        "key": "ctrl+home",
        "command": "cursorTop",
        "when": "textInputFocus"
      },
      {
        "key": "cmd+home",
        "command": "cursorTop",
        "when": "textInputFocus"
      },
      {
        "key": "cmd+end",
        "command": "cursorBottom",
        "when": "textInputFocus"
      },
      {
        "key": "ctrl+end",
        "command": "cursorBottom",
        "when": "textInputFocus"
      },
      {
        "key": "ctrl+shift+home",
        "command": "cursorTopSelect",
        "when": "textInputFocus"
      },
      {
        "key": "shift+cmd+home",
        "command": "cursorTopSelect",
        "when": "textInputFocus"
      },
      {
        "key": "ctrl+shift+end",
        "command": "cursorBottomSelect",
        "when": "textInputFocus"
      },
      {
        "key": "shift+cmd+end",
        "command": "cursorBottomSelect",
        "when": "textInputFocus"
      },
      {
        "key": "shift+cmd+left",
        "command": "-cursorHomeSelect",
        "when": "textInputFocus"
      },
      {
        "key": "shift+cmd+left",
        "command": "cursorWordLeftSelect",
        "when": "textInputFocus"
      },
      {
        "key": "ctrl+shift+left",
        "command": "-editor.action.smartSelect.shrink",
        "when": "editorTextFocus"
      },
      {
        "key": "ctrl+shift+left",
        "command": "cursorWordLeftSelect",
        "when": "textInputFocus"
      },
      {
        "key": "shift+cmd+right",
        "command": "-cursorEndSelect",
        "when": "textInputFocus"
      },
      {
        "key": "shift+cmd+right",
        "command": "cursorWordRightSelect",
        "when": "textInputFocus"
      },
      {
        "key": "ctrl+shift+right",
        "command": "-editor.action.smartSelect.expand",
        "when": "editorTextFocus"
      },
      {
        "key": "ctrl+shift+right",
        "command": "cursorWordRightSelect",
        "when": "textInputFocus"
      }
    
  18. Avatar for j. g.

    Thanks for this writeup.

    Unfortunately vscode does not support this settings file, and the relevant issue was closed (not enough upvotes)

    https://github.com/microsoft/vscode/issues/111950

    But it’s possible to customize key bindings directly in vscode:

    cmd-shift-p > Keyboard shortcuts > type cursor in the search field

  19. Avatar for Rahul Sarkar
    Rahul Sarkar

    This worked. You are a life saver. I was getting so frustrated using my PC keyboard on my Macbook.

    In the middle of learning a new programming language, it’s no good that I can’t get to the end of a line or the beginning of a line easily! Gets in the way of learning.

    Thank you so much for sharing this and help the community! Kudos and Respect!

  20. Avatar for MisterA
    MisterA

    I too would like to declare my undying love for saving me lots of swearing and lost time when developing on MacOS.

    Working fine on BigSur 11.6

    Less techy peeps: don’t be put off by earlier comments that terminal access is required — it’s not required.

    First use any editor (TextEdit if that’s all you have) to create the file and save it to an easily accessible folder, such as Documents.

    Then to access Library folder just hold down option (alt) while clicking Go menu in Finder — Library will be in the list, you can then use Finder to create the KeyBindings folder in there as normal and drag in the DefaultKeyBinding file you made earlier.

    To apply the settings without rebooting just click the apple in top left, choose Force quit… select Finder and choose Relaunch. You’ll also need to quit/restart any open applications.

    Additional useful bindings that are missing from this post to make it more productive and Windows:

    "^\\UF702" = "moveWordBackward:"; /_ Ctrl + LeftArrow _/  
    "^\\UF703" = "moveWordForward:"; /_ Ctrl + RightArrow _/  
    "^$\\UF702" = "moveWordBackwardAndModifySelection:";   /* Shift + Ctrl  + Leftarrow */  
    "^$\\UF703" = "moveWordForwardAndModifySelection:"; /_ Shift + Ctrl + Rightarrow _/
    

    Though as Other Rich says above you’ll need to disable the Mission Control ctrl left/right bindings in System preferences for those to work.

  21. Avatar for DriveByPoster
    DriveByPoster

    I too have benefitted from your wisdom -- as a Windows user going back to 2.0, having Macs in my life is always confusing, and my current job requires that I use one. This has removed a huge source of frustration. Now if only I can figure out how to deal with a Mac with a PC keyboard that has no Windows key… there aren’t enough keys in the right places to map command/control/option etc. to.

  22. Avatar for sam

    just setup on BigSur, and restarted… no change

    cat ~/Library/KeyBindings/DefaultKeyBinding.dict
    {
      "\\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
    }
    
  23. Avatar for Other Rich

    Was struggling trying to get ctrl + left/right arrow to perform left word/right word in mac BIG Sur. You will have to unmap Mission Control ctrl left/right in System Preferences->Keyboard->Shortcuts.

    Otherwise, the above worked well

  24. Avatar for KK4JO

    Just tried the suggested edit to the DefaultKeyBinding file. For me, on a Mac mini M1 running 11.5.1 results are great except that some apps won’t work. Apparently they have their own key bindings.

    Oh, same results when I either logout and log back in or reboot. We may be trying to get some windows-like behavior going but we don’t have to reboot to have our account configuration files read, just log in.

  25. Avatar for DCA

    Just installed Karabiner — Elements and all the necessary rule and no love for me on MacOS Big Sur 11.2.3. I am, however, using a Logitech K860 which comes with its own software (Logi Options) for key reassignment. I have a feeling Logi Options is preempting Karabiner — Elements.

  26. Avatar for Todd

    mosesvii’s suggestion about “Karabiner — Elements” is working great on latest version of Mac OS as of now. Installation and getting system security settings configured properly took a few minutes and was a bit confusing, but once I got it going it’s working a treat.

  27. Avatar for Steven Yong
    Steven Yong

    Works for me using Big Sur. Apps like Notes are not working.

  28. Avatar for aGreycat
    aGreycat

    I tried what mosesvii suggested and It worked perfectly for me. 2019 iMac 27″ running Big Sur 11.0.1

  29. Avatar for mosesvii
    mosesvii

    For whatever reason I was having issues with the keybinding stuff. After looking at a YouTube vid I found what I think is a better solution. At least a more comprehensive one.

    Google ‘Karabiner — Elements’and download it. It’s free… and works on my new M1 Mac Mini. Using the tool i was able to download loads of Windows keymappings at the click of a button.

    I know i could learn the mac shortcuts, and will over time. But now having my Home and End button back, among other shortcuts, is great!

    In the tool click the ‘Complex Modifications’ tab, then ‘Add rule’. In the new window, clicking the ‘Import more rules from the Internet’ button opens up a webpage with predefined key mappings. There are so many there. I found one called “Windows shortcuts on macOS”. Imported it, and enmabled the keys i wanted. No rebooting, no messing with Terminal.

    I’m super happy :)

  30. Avatar for Evey Hammond
    Evey Hammond

    Seems like I gotta do this once a year, and every time the old tricks don’t work. This time terminal commands don’t lead to a text edit file opening up, like some other users.

    I was able to do it without using terminal at all, though. I created a Text Edit file, pasted in the code Damien gave above, saved it as ‘DefaultKeyBinding.dict’(used Get Info, cmd-i to make sure it really was a .dict file not .rtf, as others have said), then placed that file in my hard drive>Library>KeyBindings. (You may need to make this folder, I think my earlier flailing around in Terminal did this. There is also a Library folder under my user name, using one or both seems to make no difference.)

    Every time I do this it seems to work in fewer programs, though. I’m on Big Sur 11.2.2, and it doesn’t work in Stickies, Messages, Open Office, and probably more. Using moveToBeginningOfParagraph versus moveToBeginningOfLine seems to make no difference. I haven’t tried Sean’s suggestion of Hammer Spoon yet.

  31. Avatar for Jess

    Same as Jam on Big Sur — make folder +file (text edit, save, and then delete extension from ‘Get Info’ menu) — but it works and I am so grateful! End key is my life.

  32. Avatar for Jam

    Still works as of 20jan20 on Big Sur.

    Had to create the folder and file. Thanks!

  33. Avatar for Sean

    Here is a solution I wrote to deal with different apps, virtual machines, remote desktop, etc. Note: You have to install the awesome Hammerspoon Lua scripting framework, and tweak some config files. But it’s pretty comprehensive, and open source.

    https://github.com/quickdraw6906/hammerspoon-pc

  34. Avatar for Gilad

    I can confirm that it works on Macbook Pro (16-inch, 2019) — Catalina 10.15.7.

  35. Avatar for Frankie
    Frankie

    Thank you so much for this post and thank you for all the comments. Using what @Rich wrote on 9/4/2020, I was able to make the Home and End keys work as I expect them to. And it works on Firefox. What a HUGE difference in reducing my stress level at the keyboard. And it works for Firefox and everything I’ve tested so far. I’m on Catalina 10.15.7.

  36. Avatar for Jeff R

    I have been putting up with this nonsense for a couple of years. Thanks for putting an end to a very real struggle. So much happier now. Thanks very much for sharing this!

  37. Avatar for Rich

    After trying to follow everything on here to no success, I found a website that had easy to follow instructions. Most importantly, my home and end keys work as I desire.


    https://www.iexplain.org/remap-home-and-end-buttons-for-external-keyboard-on-mac/

    Fire up your favorite terminal (you’re probably using iTerm2 like the rest of the world)

    mkdir -p ~/Library/KeyBindings nano ~/Library/KeyBindings/DefaultKeyBinding.dict

    The seasoned programmer could just go vi ~/Library/KeyBindings/DefaultKeyBinding.dict or more likely vim, but for the rest of us, nano works like a regular text editor.

    In the empty file you just opened, copy and paste the following:

    {
        /_ Remap Home / End keys _/
    
        /* Home Button*/
        "\\UF729" = "moveToBeginningOfLine:";
    
        /* End Button */
        "\\UF72B" = "moveToEndOfLine:";
    
        /* Shift + Home Button */
        "$\\UF729" = "moveToBeginningOfLineAndModifySelection:";
    
        /* Shift + End Button */
        "$\\UF72B" = "moveToEndOfLineAndModifySelection:";
    
        /* Ctrl + Home Button */
        "^\\UF729" = "moveToBeginningOfDocument:";
    
        /* Ctrl + End Button */
        "^\\UF72B" = "moveToEndOfDocument:";
    
        /* Shift + Ctrl + Home Button */
        "$^\\UF729" = "moveToBeginningOfDocumentAndModifySelection:";
    
        /* Shift + Ctrl + End Button*/
        "$^\\UF72B" = "moveToEndOfDocumentAndModifySelection:";
    }
    

    Having pasted it into the file, press Ctrl + X and answer with y when you get the question if you want to save.

    Well that’s it. Now you have successfully remapped the home and en button for macOS. You need to restart to make the changes happen.


  38. Avatar for Foil

    Can I get additional clarification with how to get it working on Catalina 10.15.6? I don’t really understand the instructions that @emmap has posted above. For steps 1 & 2, my user already has read and write access to the file and folder, and for step 3, I’m not really sure what any of it means.

  39. Avatar for MrVestek
    MrVestek

    This also works well on Catalina, however I find that the page will still scroll up / down when these keys are pressed, even though the behaviour is now as expected.

    Anybody know of a way to prevent this?

    Thanks so much!

  40. Avatar for emmap

    Now it works on Catalina 10.15.6:

    1- given ownership to the user MyUser to the folder /Users/MyUser/Library/KeyBindings/ and to the file DefaultKeyBinding.dict chown MyUser /Users/MyUser/Library/KeyBindings/ chown MyUser /Users/MyUser/Library/KeyBindings/DefaultKeyBinding.dict

    2- given to all users all rights to the folder /Users/MyUser/Library/KeyBindings/ and to the file DefaultKeyBinding.dict chmod 777 /Users/MyUser/Library/KeyBindings/ chmod 777 /Users/MyUser/Library/KeyBindings/DefaultKeyBinding.dict

    3- then saved the file into ASCII format with CRLF line endings instead of LF.

  41. Avatar for Kevin

    @Lolo If you copied and pasted code from others on this webpage, your double-quote character could be wrong. Replace everything that looks like a double-quote with an actual double-quote. This has caused me problems many times when writing code.

    Also, your command-* key mappings are really ctrl-* mappings because you are using the ‘^’ character at the beginning of the sequence. If you really want to use the command key, substitute the ‘^’ character with a ‘@’ character.

  42. Avatar for Lance

    @Lolo

    Try this: make sure your text in the .dict file is plain text and not rich text. To do this, go to Format > Make Plain Text and Save. Then killAll Finder and try again.

  43. Avatar for Lolo

    Either I’m dull or struggling to get this to work!

    Here’s my code; a mix of Damien’s, Brian’s and suggestions from Sergio and Lance. Running Catalina 10.15.5:

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

    Then after making sure it’s a .dict file, adding to KeyBindings, and then killall Finder in terminal, still no dice. What could I be doing wrong here?

  44. Avatar for Lance

    For those having trouble, make sure you created an actual .dict file, as opposed to a .txt file. To verify this: Right Click the file > Get Info. Expand Name & Extension to remove the ‘.txt’ if it is present and save.

    I also had to use “BeginningOfLine” instead of “BeginningOfParagraph” as user Brian mentions above.

  45. Avatar for Amy

    Thank you so much for this!! As someone brand new to Terminal, I had difficulty following only the instructions on this page to get things working. In case this helps anyone else, here’s a step-by-step of how I did it in Catalina:

    1. Open TextEdit, paste in the contents as given by Damien, and “Save As” DefaultKeyBinding.dict to your Documents folder.
    2. Open Terminal (found in Applications/Utilities/)
    3. Type in the following command and hit enter. (This will move the file you created to the desired directory): ~mv /Documents/DefaultKeyBinding.dict ~/Library/KeyBindings/DefaultKeyBinding.dict
    4. Restart your computer.
  46. Avatar for martin

    Thank you, on Catalina with Logitech K850 works fine with text editors, but Safari intercepts home/end keys to go begin/end of page, no matter if cursor is inside of a text box.

  47. Avatar for Vaibhav
    Vaibhav

    Awesone..! It saved my time and that was so frustating to work with documents. Thanks.

  48. Avatar for Magician
    Magician

    Thank you for this, it worked great

  49. Avatar for infoman
    infoman

    Thank you!!! This worked like a charm on 10.15.5. “touch” command didn’t open notepad for me. I instead used finder to navigate to the file and drag it to notepad manually.

  50. Avatar for Dylan

    I don’t think this is working on Catalina.

  51. Avatar for Sergio Schuler

    Works perfectly on Catalina — used Command instead of Ctrl though.

    SAVED MY PRODUCTIVITY. Oh my, thanks!

  52. Avatar for Rob

    WOW. What a difference it makes to have those keys remapped in a sane way. I gotta wonder what the heck apple was thinking. My guess is “Well, we only added those keys to keep that PC users happy. Let’s really mess with them. We don’t need to make them happy, we’ve got truckloads of brain-washed fanboy to keep up our User satisfaction numbers up”.

  53. Avatar for Robert

    Can confirm that Damien’s code plus Evey’s file creation instructions works on macOS Catalina (Version 10.15.5). Thank you both!

  54. Avatar for Heinz Hemken
    Heinz Hemken

    Yay! Thanks!

    [Insert lengthy, obscenity-laced vituperation over this and a number of other “natural” MacOS behaviors]

  55. Avatar for trennor
    trennor

    “3) A Notepad window will pop up. Copy-paste Damien’s code into that window and hit save. ”

    On Catalina, this does not happen and I cannot find ANY way to save this script. Textapp and Script Writer REFUSE to save it where directed. I’m at the end of my wits here; HOW is this actually accomplished? I’m attempting to save, as suggested, in ~(home/dir) ~/Library/KeyBindings/Default/KeyBinding.dict, but every time i check the file in terminal, it’s empty. What, please, is going on?

  56. Avatar for FredS

    WFH indeed… I googled again for a solution and reading the instructions I found I had created that file in the past (this issue has been annoying me long already) but it doesn’t seem to work. I have Catalina 10.15.4. Any hint?

  57. Avatar for Evey Hammond
    Evey Hammond

    Big thanks for this.

    For those like me, who aren’t regular Terminal users and who don’t just intuitively know what “create a file… in your library with the following contents” means:

    1. Open Terminal. (Applications>Utilities> Terminal)
    2. Type/copy paste in mkdir -p ~/Library/KeyBindings/ and hit enter Type/copy paste in touch ~/Library/KeyBindings/DefaultKeyBinding.dict and hit enter Type/copy paste in touch ~/Library/KeyBindings/DefaultKeyBinding.dict and hit enter
    3. A Notepad window will pop up. Copy-paste Damien’s code into that window and hit save. Here it is again:
    {
       "\\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
    }
    
    1. Quit and relaunch apps for this to take effect.
  58. Avatar for John

    As other have said this is fantastic. Thank you!

  59. Avatar for Ross

    Wonderful! This WFH period has really forced me to use my work laptop (mac) as my daily driver (as opposed to a modified Ubuntu at work) and this HOME/END thing was driving me nuts.

  60. Avatar for Eric

    You just saved me from hours of agony in quarantine! (MacOS 10.15.4)

  61. Avatar for Martin

    Worked for me on Catalina. The default behaviour in Chrome was driving me nuts.

    Many thanks!

  62. Avatar for Jonathan Feinberg

    Yayyy! Working perfectly in Catalina, and Jerry Baker’s suggestion to nuke Finder worked perfectly without a reboot.

  63. Avatar for Jerry Baker
    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

    Thanks!

  64. 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
    }
    
  65. 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.

  66. Avatar for Roger Miller
    Roger Miller

    Yay! Working on MacOS High Sierra

  67. Avatar for Eric

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

  68. 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!

    -TW

  69. Avatar for andyrak
    andyrak

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

    Hope that helps.

  70. Avatar for Ashton Cormallen
    Ashton Cormallen

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

  71. 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: https://github.com/quickdraw6906/hammerspoon-pc/blob/master/config.lua

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

  73. Avatar for Ryan

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

  74. 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
    
  75. Avatar for Alkirah
    Alkirah

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