Remap Home and End Buttons for External Keyboard on Mac

Home / End working as expected on macOS

There are few things so frustrating than having to change stuff you have in your muscle memory, like hitting ctrl + c for copy or in this case using the home and end keys on your external keyboard and have home go to the beginning of the line and end move to, you guessed it, the end of the line. This is a quick guide to fix home and end functionality for non mac-keyboards connected to a 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.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.