Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I just bought an "Apple Keyboard with Numeric Keypad", then I connected it to my Macbook Pro running Lion.

But the home and end key under the F14 key doesn't work as I expected. Say in "Pages", the home key doesn't bring the cursor to the beginning of the line, while the end key takes you to the bottom of the page.

Does anyone know how to re-map the home/end key?

share|improve this question
add comment

migrated from stackoverflow.com Jul 21 '11 at 11:50

This question came from our site for professional and enthusiast programmers.

3 Answers

up vote 21 down vote accepted

This is the default OS X behavior. You can remap the keys by editing the default keybinding file, or, if you prefer a GUI and further extensibility, by using a program like ControllerMate.

Instructions on editing the default keybinding file can be found in this blog post. To summarize, edit the file ~/Library/KeyBindings/DefaultKeyBinding.dict or create it if it doesn't yet exist. Make it look like this:

        /* Remap Home / End to be correct :-) */
        "\UF729"  = "moveToBeginningOfLine:";                   /* Home         */
        "\UF72B"  = "moveToEndOfLine:";                         /* End          */
        "$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
        "$\UF72B" = "moveToEndOfLineAndModifySelection:";       /* Shift + End  */

If there are already entries in DefaultKeyBinding.dict, just add the 4 new mappings above to the main section of your file.

Additionally, there are a couple of line movement key commands baked into OS X that may be easier on your fingers in the long run. These take you to the beginning and end of a line, respectively:

Command+ and Command+

Control+a and Control+e

share|improve this answer
This works on most of my apps like Pages and Textmate. But, I couldn't get it working in Terminal –  user8207 Jul 22 '11 at 21:54
Right. Terminal is another story, and you'll need to tell it how you want the Home and End keys to behave. You can do that in Terminal -> Preferences -> Keyboard. Set the Home key to send control-a and End key to send control-e. Those are the Emacs-style keybindings that the Terminal uses for line movement by default. It'll mimic the regular home/end movement you're after. –  michaelmichael Jul 22 '11 at 22:40
Thanks again Michael. I'll try it out tonight when I get back to my laptop. –  Kevin Ren Jul 25 '11 at 0:44
+1 Thank you! This has literally bugged me for years! –  ckpepper02 Nov 25 '13 at 18:17
add comment

I have a macbook running Lion. michaelmichael's answer did not work for me. This free app did work: http://pqrs.org/macosx/keyremap4macbook. I used its "Use PC Style Home/End" (Change Home to Command+Left) ..." option.

You might try http://doublecommand.sourceforge.net. I got the link to KeyRemap4MacBook from there. I did not try doublecommand. Since I have a macbook, I tried KeyRemap4MacBook first. It worked, no need to mess with doublecommand...

The most frequent commands should have the shortest keyboard commands. Whoever at crApple thought that navigating to the top/bottom of the entire document would be more frequent than navigating to the beginning/end of the line was cracked in the head, and certainly wasn't a programmer. If it's just a legacy item they hesitate to fix, they need to be brave and just fix it.

Thanks KeyRemap4MacBook, I can feel my sanity returning already.

share|improve this answer
add comment

I followed this blog post and it did the "home" and "end" key bindings as well as a few other userful adjustments.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.