Mac OS X Home and End Keys
March 13th, 2006
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 :)



April 1st, 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?
June 14th, 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.
June 28th, 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.
June 28th, 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.
July 10th, 2006 at 10:56 pm
Thanks so much! It makes things sane.
July 11th, 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.
August 10th, 2006 at 9:44 pm
Doesn’t seem to effect application like Eclipse at all. I still have to use the retarded @pple+arrow.
August 31st, 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.
October 22nd, 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! ^^
November 14th, 2006 at 12:00 pm
[...] 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. [...]
November 18th, 2006 at 5:51 am
[...] Thank you http://www.starryhope.com/tech/2006/mac-os-x-home-and-end-keys/! [...]
November 23rd, 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!
November 23rd, 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.
December 1st, 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
December 18th, 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
January 17th, 2007 at 10:48 am
The macro program Keyboard Maestro fixed this for me.
January 18th, 2007 at 9:39 am
Any luck yet with the Firefox patch?
January 18th, 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
April 19th, 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.
April 19th, 2007 at 10:56 am
Also forgot to mention – THANK YOU SO MUCH for this. It’s a lifesaver.
April 20th, 2007 at 2:27 pm
[...] 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). [...]
May 4th, 2007 at 2:57 am
This worked wonders!!! Thanks a bunch!
June 28th, 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…
July 13th, 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?
July 18th, 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.
July 30th, 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.
August 1st, 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.
August 18th, 2007 at 2:05 am
James M has the greatest response here. Accomplishes exactly what you want, with a key functionality already defined.
August 21st, 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. :)
August 28th, 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!
September 17th, 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.
September 21st, 2007 at 4:22 am
[...] 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 [...]
October 6th, 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?
November 9th, 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!
November 12th, 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.
December 21st, 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.
January 3rd, 2008 at 1:35 pm
Windows Keybindings:
http://www.hcs.harvard.edu/~jrus/Site/KeyBindings/Windows%20Bindings.dict
Emacs (using Esc metakey):
http://www.hcs.harvard.edu/~jrus/Site/KeyBindings/Emacs%20Esc%20Bindings.dict
Emacs (using Opt metakey):
http://www.hcs.harvard.edu/~jrus/Site/KeyBindings/Emacs%20Opt%20Bindings.dict
Customizing the Cocoa Text System:
http://www.hcs.harvard.edu/~jrus/Site/cocoa-text.html
February 16th, 2008 at 10:13 pm
[...] 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 -> [...]
February 27th, 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.
March 23rd, 2008 at 2:21 am
[...] 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, [...]
April 18th, 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!
April 25th, 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.
April 27th, 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.
July 4th, 2008 at 10:00 pm
Worked like a charm in VMWare Fusion. Thanks for the help!
Anu.
July 15th, 2008 at 9:55 am
[...] 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! [...]
July 24th, 2008 at 9:37 pm
Thank you so much! That was totally painless!
August 28th, 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
September 12th, 2008 at 8:25 am
[...] 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 [...]
September 17th, 2008 at 5:13 pm
I have found a simple way in OSX Leopard which is simply
September 20th, 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:”;
}
November 27th, 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.
December 27th, 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
January 8th, 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.
March 29th, 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…
April 24th, 2009 at 12:40 am
Wow, fantastic tip! I just got a Mac and those keys were driving me crazy.
May 12th, 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 :/
May 13th, 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.
May 24th, 2009 at 9:57 pm
Thank you very much. This was very helpful.
May 28th, 2009 at 4:31 am
Does not work in Leopard. Running 10.5.7
June 12th, 2009 at 5:30 am
[...] 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 [...]