DEV Community

Cover image for macOS Tip: How-To Get The Home And End Keys On A Windows Keyboard To Work
dev_neil_a
dev_neil_a

Posted on • Updated on

macOS Tip: How-To Get The Home And End Keys On A Windows Keyboard To Work

Introduction

Whilst macOS does allow the use of non-Macintosh layout keyboards to be used, some of the keys don't work as intended in some applications. For myself, the main two are the home and end keys. In some applications, such as VS Code, they work as expected (so to the beginning or end of a line) but in another applications, such as Apple's Pages they may not work.

To resolve this, the key bindings can be adjusted to make them respond as they would on Windows or Linux.

This article will provide a step-by-step guide on how to get them to work.

Solution

  1. In Finder, press SHIFT+CMD+g to open up the Go to Folder prompt.

  2. Type in ~/Library and press enter.

  3. When the new Finder window appears, scroll down until you see a folder named KeyBindings. If the folder does not exist, create it.

  4. Open a text editor, such as VS Code.

  5. Create a new file and save it into the KeyBindings folder with a file name of DefaultKeyBinding.dict.

  6. In the file, paste in the below:

    {
    /* 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 */
    }
    
  7. Save the file and exit the text editor.

  8. Reboot the Mac and log back in.

  9. Open up the Pages application.

  10. Create a new file, type some text and use the home and end keys. They should now work as they do on Windows or Linux.

Conclusion

I hope you found this useful. Thank you for reading and have a nice day.

Top comments (0)