Remap Home and End key behaviour on a Mac

MX Keys

The following terminal script can be used to map Home and End keys on macOS so they work in the same way as they do in Windows and Linux: Home – beginning of the line, End – end of the line, Shift + Home – select text between cursor and beginning of the line, etc.

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
 

Log off and log back on for changes to take effect.
Credit: Remap Home and End Keys? – Apple Community
 
October 2022
Mac Mini M1 2020
macOS Monterey (12.6)
Logitech MX Keys

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *