Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

migrated from Jul 21 '11 at 11:50

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

up vote 35 down vote accepted

One option is to create ~/Library/KeyBindings/ and save a property list like this as ~/Library/KeyBindings/DefaultKeyBinding.dict:

  "\UF729"  = moveToBeginningOfLine:;
  "\UF72B"  = moveToEndOfLine:;
  "$\UF729" = moveToBeginningOfLineAndModifySelection:;
  "$\UF72B" = moveToEndOfLineAndModifySelection:;

Quit and reopen applications to apply the changes. Note that DefaultKeyBinding.dict is not supported by some applications like Xcode or Firefox.

In Terminal you can assign home (↖) to control-a and end (↘) to control-e from Preferences > Settings > Keyboard. That will leave you with no key combinations to scroll to the top or bottom of a window though.

It might be easier to just use the default keybindings. In most native text views:

  • control-A or option-up goes to the beginning of a paragraph
  • control-E or option-up goes to the end of a paragraph
  • command-left goes to the beginning of a line
  • command-right goes to the end of a line
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

Another option is to enable the "Use PC Style Home/End" setting in Karabiner (formerly KeyRemap4MacBook):

The setting is defined in Resources/include/checkbox/for_pc_users.xml.

You can also save a file like this as ~/Library/Application Support/KeyRemap4MacBook/private.xml:

<?xml version="1.0"?>
    <autogen>__KeyToKey__ KeyCode::HOME, ModifierFlag::NONE, KeyCode::A, VK_CONTROL</autogen>
    <autogen>__KeyToKey__ KeyCode::END, ModifierFlag::NONE, KeyCode::E, VK_CONTROL</autogen>
    <autogen>__KeyToKey__ KeyCode::HOME, VK_SHIFT | ModifierFlag::NONE, KeyCode::A, VK_CONTROL | VK_SHIFT</autogen>
    <autogen>__KeyToKey__ KeyCode::END, VK_SHIFT | ModifierFlag::NONE, KeyCode::E, VK_CONTROL | VK_SHIFT</autogen>

Then open the KeyRemap4MacBook application, press the ReloadXML button, and enable the setting. See for more information.

share|improve this answer

I would suggest you the awesome keyremap4macbook, it's free amd despite the name it works on any mac (not necessarily macbooks) and here you can find the easiest way to change the default behaviour of home/end buttons to work like they should (IMO)

share|improve this answer

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

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

We like answers to be more than just a single line. Ideally, you want to explain why your answer is *right." It also helps to provide links, citations, and/or screen shots. Please review our help section How to Answer on writing good answers to questions – Allan May 24 at 23:13

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.