• Google Buzz

Mac OS X Home and End Keys

Update: Now you can skip all these instructions and just download my KeyFixer application to fix your home and end keys. Read the new article …

The default behavior of OS X’s “home” and “end” keys drives me nuts. In every other operating system that I’ve used, these keys move your cursor to the beginning (home) or end (end) of your current line. Thankfully, Dreamweaver on the mac behaves this way, but everything else behaves oddly (usually moving you to the beginning or end of the entire document, and sometimes moving just the focus, while leaving the cursor in place).

Today, I decided to try to change this default behavior, and thanks to this blog post by Jon Evans, it was easy. Thanks for the tip Jon!

Update: If the files don’t already exist, you need to create them. Here’s the easy way to do it in Terminal (easier, because Finder doesn’t let you see hidden files easily).

Open Terminal (Applications -> Utilities -> Terminal) and type the following commands:

cd ~/Library/

then

ls

Now, if you don’t see the KeyBindings folder, type

mkdir KeyBindings

Go into the KeyBindings Directory

cd KeyBindings

Make or Edit DefaultKeyBinding.dict

nano DefaultKeyBinding.dict

This opens the nano text editor. Paste these lines from the tutorial in into the file.

{
        /* Remap Home / End to be correct  */
        "\\UF729"  = "moveToBeginningOfLine:";
        "\\UF72B"  = "moveToEndOfLine:";
        "$\\UF729" = "moveToBeginningOfLineAndModifySelection:";
        "$\\UF72B" = "moveToEndOfLineAndModifySelection:";
}


Update: After reinstalling my computer and upgrading to OS X 10.4.7 the above lines did not work. It seems that not all browsers (including mine) were displaying the code properly and the biggining “\” character was being cut off. Sorry about that! If this code didn’t work for you before, try it again now.

I also did some seaching and found this article on the TextMate blog. The following lines from that article add a “fix” for the page up and page down keys.

{
    /* home */
    "\\UF729"  = "moveToBeginningOfLine:";
    "$\\UF729" = "moveToBeginningOfLineAndModifySelection:";

    /* end */
    "\\UF72B"  = "moveToEndOfLine:";
    "$\\UF72B" = "moveToEndOfLineAndModifySelection:";

    /* page up/down */
    "\\UF72C"  = "pageUp:";
    "\\UF72D"  = "pageDown:";
}

press control-x to exit (make sure you save the file).

Now, you don’t need to restart OS X, just any applications that you want to use the new KeyBindings in. Remember, this still doesn’t work right in Firefox. Also remember that you’re changing system setting (in this case, just for the user you’re logged in as) and you should always be careful when making system changes :)

  • Google Buzz

70 Responses to “Mac OS X Home and End Keys”

  1. Bill D 01. Apr, 2006 at 2:45 am #

    Am I supposed to create the folder “KeyBindings” and then create a text file called “DefaultKeyBinding.dict”?

    And then am I supposed to restart OSX?

  2. blah0 14. Jun, 2006 at 5:41 am #

    This works great for Terminal.app. Unfortunately it won’t work in conjunction with the “DoubleCommand” extension (http://doublecommand.sourceforge.net/) If you are using DoubleCommand you must disable “PC style home and end keys” first.

  3. James M 28. Jun, 2006 at 12:12 am #

    Actually, the HOME and END keys do exactly what they should in OS X; they scroll to the very top or bottom of the current document. To go to the start or end of the current line, all you need to do is use CMD+left-arrow or CMD+right-arrow

    This all seems totally pointless to me and is just a futile exercise in trying to force OS X to conform to a keybinding from Win XP that you can’t seem to unlearn.

  4. lesli 28. Jun, 2006 at 7:22 pm #

    THANK YOU! This has been one of the things that has frustrated me most since getting a Mac – beginning and end of line are pretty basic and should really have one key (not cmd + key) functionality.

  5. Bob Garush 10. Jul, 2006 at 10:56 pm #

    Thanks so much! It makes things sane.

  6. Alan S 11. Jul, 2006 at 7:44 pm #

    To James M: It is never pointless to make applications behave the way you want them to. Moreover, configurability is a desireable thing because it helps people who are switchng from one OS to another.

    As far back as DOS days, my word processer (PC-Write) make it very easy to change key-bindings with the idea that key press behavior should seem “normal” to the user. If I press Page-Up I am actually expecting the page to move down so I can see higher up. Some people would want the Page-Up key to literally move up the page.

    Having a personal laptop or workstation means I can customize it to work most effectively and efficiently for me.

  7. Link M 10. Aug, 2006 at 9:44 pm #

    Doesn’t seem to effect application like Eclipse at all. I still have to use the retarded @pple+arrow.

  8. Jason Stahls 31. Aug, 2006 at 6:02 pm #

    James M: Just for my own historical knowledge can you name a system that uses this sort of key binding? It’s not just Windoze that uses home/end for the begining/end of a line, so far every OS I’ve used (at least to the best of my recolection) uses them for begining/end of line, be that Solaris, VMS, Linux, BSD, or Win/DOS.

  9. John Sexton 22. Oct, 2006 at 3:00 am #

    omg, thank you. I too use many OSes (HPUX, Linux, Windows and Mac OSX every day) and the home, end, page up, page down keys have been killing me on the Mac. The Mac is my favorite desktop OS and ‘nix in general my favorite server OS and no matter how used to OSX I’ve become those keyboard commands never ever felt right (apple+arrow what?). I am ok with apple+C/X/V for copy, cut, paste but hitting home and end all the time and getting either no response or the wrong response sucked. This post just improved my life. You rock! ^^

  10. jasminerain 23. Nov, 2006 at 12:51 pm #

    It still doesn’t work for me in Thunderbird, Firefox, and Eclipse. Does anyone know of a way to fix this, since these are the apps that I use most often for typing?

    Thanks!

  11. Jim 23. Nov, 2006 at 4:33 pm #

    jasminerain,
    Yes, I do know how to fix it in Firefox, but it’s not exactly an easy process. I’m working on a script that you can run to patch your copy of Firefox. It’s the same deal with Thunderbird.

  12. Ben 01. Dec, 2006 at 9:52 am #

    Okay eclipse doesn’t follow anyones default key layout, it is standard based on the version you down load… so basicly to get this to work do this:

    Eclipse -> Preferences -> General -> Keys

    Under the pull down menu Catagory select Text Editing and under name Line Start and Line End for home and end respectfully

    Select the text in the Assignments window
    Hit Remove
    under Name press the home key
    select add

    You should now have the home and end keys going to the begining and end of the line.

    Most of this came from here but you don’t need to do anything hard from what I found:
    http://www.kelek.com/blog/2006/09/16/fixing_home_end.html

  13. Joe 18. Dec, 2006 at 11:04 pm #

    While this works great for a number of applications, it doesn’t work at all for the terminal.
    I did find http://tech.inhelsinki.nl/gnu_developement_under_mac_os_x/ which helped though

  14. Christopher M 17. Jan, 2007 at 10:48 am #

    The macro program Keyboard Maestro fixed this for me.

  15. Jordan 18. Jan, 2007 at 9:39 am #

    Any luck yet with the Firefox patch?

  16. Jim 18. Jan, 2007 at 11:10 am #

    Jordan,
    Actually, yes. Anyone who’d like to beta test the Firefox patch, send me an email at jim at starryhope

  17. Michael Jordan 19. Apr, 2007 at 10:55 am #

    James M, cry us a river. Home = home of the current line, end = end of the current line. It’s a basic UI principle.

  18. Michael Jordan 19. Apr, 2007 at 10:56 am #

    Also forgot to mention – THANK YOU SO MUCH for this. It’s a lifesaver.

  19. Jason 04. May, 2007 at 2:57 am #

    This worked wonders!!! Thanks a bunch!

  20. Martin 28. Jun, 2007 at 3:40 am #

    Just an FYI – while the Home and End keys work logically in Dreamweaver, the PgUp and PgDn keys don’t, but they can be easily modified by going to Dreamweaver > Keyboard Shortcuts.

    If you haven’t already, you’ll have to duplicate the standard set to make a modifiable set. Then select “Code Editing” from the drop down and locate “Move to start of page” and “Move to end of page” and set them to the appropriate keys.

    Thanks to the creator for these easy fixes for the keyboard! Apple’s default is unnatural and annoying and definitely slows the productivity if you didn’t grow up with it…

  21. mathew 13. Jul, 2007 at 8:44 pm #

    I’m using Firefox on Linux.

    Home scrolls to the start of the page. End scrolls to the end of the page. Just like the Mac.

    I guess this is some Windows thing I’m not used to?

  22. tom 18. Jul, 2007 at 5:15 pm #

    “Actually, the HOME and END keys do exactly what they should in OS X; they scroll to the very top or bottom of the current document. To go to the start or end of the current line, all you need to do is use CMD+left-arrow or CMD+right-arrow

    This all seems totally pointless to me and is just a futile exercise in trying to force OS X to conform to a keybinding from Win XP that you can’t seem to unlearn.”

    ACTUALLY, if you are using a MacBook Pro, there is no page up page down option.. only home, end, and beginning and end of line. Scrolling a page at a time with the keyboard is a mystery.

  23. Eric 30. Jul, 2007 at 12:32 am #

    Quote from James M
    >> This all seems totally pointless to me and is just a futile exercise in trying to force OS X to conform to a keybinding from Win XP that you can’t seem to unlearn.”

    Here’s the reason for me: I use a windows PC at work. Mac at home. For me, it’s difficult to keep the key combinations straight. To make matters worse, I sometimes access my work (PC) computer remotely from home (Mac). It’s just nice to have options.

  24. Marcel 01. Aug, 2007 at 12:57 am #

    Thanks for the hint Mac OS X is driving me nuts can’t wait until Ubuntu runs nice on the new santa rosa mac book pro, so that I can ditch Mac OS X. I want to configure “everything” like I can with KDE.

    Anyways @tom: On the mac book pro you can page up and page down if you hold down the fn key while pressing the page up or down keys.

    cheers

    Marcel

    http://www.cfavatar.com

    P.S. Don’t start a flame war cause I prefer KDE. My employees hate it which is ok too.

  25. Alan 18. Aug, 2007 at 2:05 am #

    James M has the greatest response here. Accomplishes exactly what you want, with a key functionality already defined.

  26. Stacia 21. Aug, 2007 at 6:43 am #

    OMG – I love you!!! The OS and Firefox fixes have made my life with a new iMac so much easier. I tried to make the .dict file myself but it didn’t work for some reason – you’re a real life saver. :)

  27. Fester Addams 28. Aug, 2007 at 11:53 pm #

    Thank you all!

    This has been driving me crazy. The canned response from mac heads seems to always be “you’re just not doing it right.” When every other computer system on the planet does one thing and one does it differently, it’s nice to be able to make that one conform. thank you!

  28. Joey Bootz 17. Sep, 2007 at 2:14 pm #

    In my opinion coming up with a “correct” or “more correct” shortcut, and indeed in determining any behaviour in UI design, should be driven by most-use winning out over others.

    That is, how many times a day do you need to go to the absolute end of a document compared to how many times do you need to go to the end of a line? Everyone’s needs are different, but for the work that I regularly do, I need to go to the end of a document about 1 out of 1,000 times. Whereas I need the end-of-the-line functionality 999 out of 1,000. So I prefer the default behaviour of “end key”=”end of line” ala windows.

    Maybe the MAC designers have a pressing need to get to the end of their documents more than I do? Or do they just want to be “different”? Who knows.

  29. Ben 06. Oct, 2007 at 12:12 pm #

    So with a MacBook Pro and OS X 10.4.10, Command and Left Arrow is home for the current line and Command and Right Arrow is end for the current line and this works on the laptops keyboard.

    If I plug in the Apple usb keyboard, neither pressing Home or End on their own, or with the Command key work?

    Does anyone know how to make the home and end keys work when using and external usb keyboard?

  30. Mirko 09. Nov, 2007 at 6:47 pm #

    Thank you!
    That’s been driving me nuts also!

    To Ben:
    I’m also using external USB keyboard and after this DefaultKeyBinding.dict, home, end, pageup and pagedown keys work the way I want it – home/end of current line and page up/down with the cursor!

  31. MikeFM 12. Nov, 2007 at 9:29 pm #

    To bad Apple is to retarded to use normal keybindings by default. These little quirks take a great platform and hinder it in stupid little ways. Every other platform I’ve used in the past decade or so uses standard meanings for certain keys and key bindings and Apple has to go and make them funky for no real purpose – it certainly doesn’t make the system work any better.

  32. Nico 21. Dec, 2007 at 3:32 am #

    This app saves me ! I can’t manage to learn the macosx shortcut. The “end key” ala windows is the best way for me. Thank you so much.
    The mac only users can’t understand this feature as the never work on windows.

  33. Dr Fence 27. Feb, 2008 at 12:16 am #

    FYI when modifying in eclipse, you have to remove the “Text Start” and “Text End” keybindings. It took me a while to figure this out.

  34. lorenzo 18. Apr, 2008 at 8:07 pm #

    Honestly, you can’t imagine how PLEASED I am. This thing drove me NUTS for a long long time. And yeah mac is retarded for not offering a feature to fix these things.

    Thanks!

  35. Ben 25. Apr, 2008 at 12:40 am #

    Anyone miss having an “insert” key on the Mac? Don’t think I’ll be mapping that functionality any time soon. Thank you for these tips on Home and End, I thought my keyboard was broken the first time I tried to use them. I used Mac from 1984 to 1997 and I don’t remember having these keys, so when I saw them on my new Mac I thought they would behave in the conventional manner. I’d be pretty disappointed if “Return” didn’t include a line feed, two keys named “delete” is a bit weak too – even with the little [X]> symbol on one of them. The warnings you get about removing USB devices without first ejecting take a little getting used to as well.

    Overall a great product.

  36. Mr. Bean 27. Apr, 2008 at 12:43 pm #

    Thank you so much for releasing this fix! The “wrong” behaviour of those keys has been one of the most annoying things on the MAC – which is pretty flawless otherwise :-)

    The Firefox fix works like a charm, too.

  37. Anuraag Bhardwaj 04. Jul, 2008 at 10:00 pm #

    Worked like a charm in VMWare Fusion. Thanks for the help!

    Anu.

  38. Charlie 24. Jul, 2008 at 9:37 pm #

    Thank you so much! That was totally painless!

  39. rama 28. Aug, 2008 at 1:53 am #

    Thank you!
    now this key work as i want :)

    it was REALLY boring to edit something on a remote server without end/home, when i have to edit something of long it takes mins to get to the right point.

    Also, cmd+arrow, doesnt’t work on terminal+ssh+pico on a remote server, just to reply to one of the first message :)

    Cheers

  40. bk 17. Sep, 2008 at 5:13 pm #

    I have found a simple way in OSX Leopard which is simply

  41. Patrick 20. Sep, 2008 at 6:45 am #

    I added the Control+End to go to the end of document and Shift+End+End to select all to the end of document.

    {
    /* home */
    “\UF729″ = “moveToBeginningOfLine:”;
    “$\UF729″ = “moveToBeginningOfLineAndModifySelection:”;
    “^\UF729″ = “moveToBeginningOfDocument:”;
    “$^\UF729″ = “moveToBeginningOfDocumentAndModifySelection:”;

    /* end */
    “\UF72B” = “moveToEndOfLine:”;
    “$\UF72B” = “moveToEndOfLineAndModifySelection:”;
    “^\UF72B” = “moveToEndOfDocument:”;
    “$^\UF72B” = “moveToEndOfDocumentAndModifySelection:”;

    /* page up/down */
    “\UF72C” = “pageUp:”;
    “\UF72D” = “pageDown:”;
    }

  42. Steve 27. Nov, 2008 at 6:24 am #

    In my browser your instructions are showing up as 2 \’s, but what worked for me is just one, like “\UF…”. OK someone else probably already said that, but it’s ok.

    Thanks so much! Editing code in XCode just became much less annoying.

  43. Ara 27. Dec, 2008 at 6:17 pm #

    It didn’t work for me. I followed every step and now my home and end keys don’t do anything at all. I tried it in mail application and in nano editor. Anyone experiencing the similar problems?

    Cheers

  44. madslund 08. Jan, 2009 at 1:58 pm #

    Using only one \ worked for me as well. Thanks Steve.

    Also, the ~ in the very first line of the instructions looks like a – on my screen.

  45. Ted 29. Mar, 2009 at 10:18 am #

    Why are there so many people determined to do it the Wrong Way? I came from the Windows world, and I’ve had a Mac for the last couple of years, but you don’t hear me complain about the missing Start menu…? Cmd+Arrow is so ridiculously superior to using out-of-the-way keys like Home or End. Sorry everybody – it’s just Fitts Law – the Command and arrow keys are closer and easier to push than Home and End. Why would you WANT to use the Home and End keys for something so common as finding your way to the start or end of a line?

    Go ahead – type more slowly. It’s not like I mind being more productive than you are…

  46. Moridin 24. Apr, 2009 at 12:40 am #

    Wow, fantastic tip! I just got a Mac and those keys were driving me crazy.

  47. Anonymous 12. May, 2009 at 1:18 pm #

    @Ara: It won’t work for me neither (OS X 10.5.6) — I dearly miss this mapping in the ‘options’ tab of the Microsoft Natural Pro Keyboard Driver :/

  48. Mickey 13. May, 2009 at 4:58 pm #

    Thanks for the tip! It’s great to remap the keys to do exactly what I, the user, want… not what Apple thinks I should be doing.

    Btw, the Mac Book Pro without Page Up/Down keys issue simply drives me nuts. Pressing Fn-Page Up/Down is not acceptable for me — I often eat with my left hand and browse with my right hand, so I’m not going to use two hands just to page up/down. At the very least, Apple should have provided a Command-Page Up/Down alternative.

  49. Lothealian 24. May, 2009 at 9:57 pm #

    Thank you very much. This was very helpful.

  50. Jeff 28. May, 2009 at 4:31 am #

    Does not work in Leopard. Running 10.5.7

  51. BDP 15. Jul, 2009 at 6:19 pm #

    Thanks, I’ve been slowly accepting Mac OSX. For the most partOSX is great, but little odd ball things like the strange NON STANDARD behavior is frustrating and genuinely make it near impossible to work on as a developer that must use multiple environments.

    There are numerous easy ways to quickly scroll to the top / bottom of the document, using the mouse, scroll bars, wheel, keyboard shortcuts. “Home” and “End” are the accepted standard way to move the the home and end of a line. Changing the behavior just makes OSX that much more proprietary. It certainly seems like uncle Steve being obnoxious, as I can see absolutely no benefit to the end user what so ever.

    I know I need to jump to the start/end of a line A LOT more often than jumping to the beginning / end of a document. As a programmer using native OSX applications for coding / text editing is virtually useless to me. So much so that I end up launching all my development tools on via an X session.

  52. Alex D 28. Jul, 2009 at 5:50 am #

    Customization is everything here ! Doesn’t matter if you like it or not, but don’t force users to conform to what Apple thinks is good. There’s nothing more annoying than a piece of sw that some developer thought it would be smart than you.
    As for the behavior of these keys, for those of you who are not around for some time, the behavior to begin and end of documents has always been CRTL-HOME and CTRL-END combo (or whatever freaky key apple decided to use).

    For the frustrated people, there may be another path which is using xmodmap to change the keys mappings. Experiment by yourself. I have remapped several so I would keep my sanity when using Xcode.

    In time: xmodmap -pke diskays the current mappings.

  53. rich 28. Aug, 2009 at 9:51 am #

    James, james, james….

    This is the standard BIOS functionality here.
    Home/End are supposed to work on the line. That other is MAC for ‘think differently’ IE WORK differently. I like the way the BIOS functions, thank you.

    Page up/down are supposed to scroll, which of course is limited in a console.

    Its the fact that mac has always had this non-standard behavior that drives me nuts.And that Apple META instead of CTRL-V for paste needs to be fixed.Apple keys should map to the rest of the standards,too.

    Linux does it right.Its not a ‘windows’ issue. Its a standards issue. Apple doesn’t care for the set ANSI standard, that’s all.I don’t care about the display portion of it because its a pain to code and ugly.I prefer doing it right the first time.

  54. Cool Person 22. Sep, 2009 at 1:18 am #

    The behaviour of the home and end keys are by FAR the most annoying “feature” of OS X. I constantly hit them by mistake while coding when I want to press page up or down, and this drives me crazy to no end. Option + Home/End should be the default keybinding to reach the top or bottom, imo.

  55. PiEp 16. Oct, 2009 at 2:09 pm #

    Definitely works in Snow Leopard. This was driving me nuts, but this tip fixed it. Thanks!

  56. mitchell 08. Nov, 2009 at 3:32 am #

    @Ted (comment 54)
    The arrow keys are out of the way just as much as the home or end keys. Anything that can’t be pressed while staying over the home row is out of the way. Vi enthusiasts (not me) could easily call your method the “Wrong Way” and they probably kill you on productivity. Besides, I would say that since you are already moving your hand off the home row for the damn arrow keys that having to use one in combination with a modifier key (CMD) makes it more work than the single-key approach of home or end.

    Ah, that takes care of my urge to comment to folks who’ll never be back around see the reply.

    For any other folks interested in changing up some key bindings on you mac there’s a handy GUI program for doing so here:
    http://www.cocoabits.com/KeyBindingsEditor/

  57. Rob 26. Dec, 2009 at 3:55 am #

    It’s just Shift + Apple Key + Left Arrow = Selects everything to Home
    It’s just Shift + Apple Key + Right Arrow = Selects everything to End

    • Josh 12. Mar, 2010 at 2:16 am #

      This was very helpful, thank you Rob.

  58. Larry 14. Jan, 2010 at 11:46 pm #

    check out #66. Mitchell’s KBE actually works!!!! Finally – I get the expected response to and End and Home key that I want/expect. Thank you so much!

  59. anonymous 25. Jan, 2010 at 6:50 pm #

    Thank you very much! I love it!

Trackbacks/Pingbacks

  1. KeyFixer - Fix Your OS X Home and End Keys - Starry Hope Productions - 14. Nov, 2006

    [...] A few months ago, I wrote a short article about how to fix the “home” and “end” keys in OS X. I published a step-by-step guide to adding your own custom key bindings via the command line. Many people found this too much of a pain, so I decided to make an easy clickable solution. [...]

  2. CodeWord: Apokalyptik » Blog Archive » Oh sweet jeebus! Home and End working properly in TextEdit on OSX - 18. Nov, 2006

    [...] Thank you http://www.starryhope.com/tech/2006/mac-os-x-home-and-end-keys/! [...]

  3. KeyFixer - Firefox Version - Starry Hope Productions - 20. Apr, 2007

    [...] To help in the ongoing search to make the “home” and “end” keys work in Mac OS X like they work in other operating systems, I give you the Firefox version of KeyFixer. (See here and here for background on the problem and info on how to fix this issue in other apps besides Firefox). [...]

  4. Stephen’s Personal Blog » Blog Archive » Mac: Day 3 - 21. Sep, 2007

    [...] a per window feature. So, I looked up how to revert them in to Windows standards. This blog has a great utility that will fix Mac and Firefox. Install the utility and then run it to change the remap the key [...]

  5. Critiche da switcher niubbo - Videogiochi Forum su Multiplayer.it - 16. Feb, 2008

    [...] ringraziamo l’ onnipotente/onnipresente/onniscente/whatever Trust per aver trovato questi link: Mac OS X Home and End Keys – Starry Hope Productions KeyFixer – Fix Your OS X Home and End Keys – Starry Hope Productions -> [...]

  6. Feel free to trash OS 9/Classic, more | Paul Vaughn: The Mac Guy - 23. Mar, 2008

    [...] methods to change this behavior, mostly, using the Terminal like this one from StarryHope.com (www.starryhope.com/tech/2006/mac-os-x-home-and-end-keys). That’s OK for those who don’t mind plumbing the depths of Unix through the Terminal, [...]

  7. Omega Point » Blog Archive » Correct Home/End functionality in Firefox on Mac OSX - 15. Jul, 2008

    [...] How cool is this? Jim Mendenhall at Starry Hope offers some help to us Mac Switchers. Long one of the top Google results for “osx home end“, Jim developed a small app to replace the Mac’s default key behavior with that of every other windowing system ever. (That’s right, nitpickers. Ever.) Unfortunately, it didn’t work in Firefox… until now! [...]

  8. Christian Lalor · My Mac experience so far - 12. Sep, 2008

    [...] key cursor movement. This is quickly becoming the most annoying thing for me. I’ve found partial solution (partial in that it doesn’t seem to work in every program). Xcode allows you to setup [...]

  9. Making the Home and End Keys work in Eclipse 3.4 on Apple Mac OSX - Rob@Rojotek - 12. Jun, 2009

    [...] in the comments of the article of Starry Hope – Mac Home and End Keys are some instructions for how to make the home and end keys work well as begin and end line in [...]

Leave a Reply