Skip to main content
Random Coding

Photo by Bing image creator

Rebinding the Home and End Keys in a Mac to Work Like They Do in Windows

I switch between Windows and Mac quite regularly because I use a Mac for work and Windows when I'm at home. I've gone through many different keyboards but for the past year or so I've primarily been working on a Keychron K10. It's great because it can switch between Mac and Windows mode so I don't need to remap any keys.

However, the one thing that bugs me (and always catches me out at the worst times) is how the Home / End keys work in Mac. I never noticed this before because I would switch between the Macbook keyboard / a magic keyboard and a Window keyboard.

In Windows, pressing Home takes you to the first character of the line you're on and pressing End takes you to the last character. But on Mac, it does this weird thing similar to what Page Up / Page Down does on Windows.

The easiest way to fix this seems to be just remapping the keybindings.

Run the following in a terminal

mkdir -p $HOME/Library/KeyBindings
echo '{
/* 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 */
}' > $HOME/Library/KeyBindings/DefaultKeyBinding.dict

And you're done! Just keep in mind that you need to restart the application before these changes take effect.