Fix Home and End Keys on Mac OS X
Nothing in this world makes less sense then how Apple decided to make Home, End, Page-Up, and Page-Down work.
I’m not sure where, when, and why this started. But on every other modern day operating system, these keys work like this:
- Home -> move the cursor to the beginning of the line - End -> move the cursor to the end of the line - Pg-Up -> move the cursor up the length of the viewport - Pg-Dn -> move the cursor down the length of the viewport
Now I don’t know why I am even repeating these descriptions. As much as the sky is blue and earth is below our feet, everyone knows what these buttons do.
Unless you are on a Mac. Apple in its infinite wisdom decided this wasn’t a good idea. These buttons don’t make any sense if you have a one button mouse, so let’s make them useless!
- Home -> move (nothing, not even the cursor, just your view) to the beginning of the DOCUMENT - End -> move (nothing, not even the cursor, just your view) to the end of the DOCUMENT - Pg-Up -> move (nothing, not even the cursor, just your view) up the length of the viewport - Pg-Dn -> move (nothing, not even the cursor, just your view) down the length of the viewport
Now, just the fact alone that you can’t, with a single key press, move the end of the sentence is beyond me. Who the hell would want to do that?! But ALSO, the cursor doesn’t move with the view port. So if you find something interesting as you are paging around, you can’t edit it without brining your one button mouse over. Some how, I am reminded of a conversation in “Dude, where’s my car?”
“DUDE! SWEEET!”
Now, maybe that wasn’t the exact conversation Steve Jobs had with himself when he thought of that “feature.” But at most it was replaced with “GNARLY!”
What’s so absurd about this is how no one ever complains about it. I mean, giving this behavior to these buttons essentially renders them USELESS! I can’t believe there are so many people out there that just look at these four buttons and say, “What the heck is that! I’m not using THEM!” Because if you did use them, you would realize how terrible the behavior is.
At any rate, at least Apple designs great software. You can change this absolutely idiotic behavior by editing some local preferences. Here is how:
1. Create a new text file at:
Users/[your username]/Library/KeyBindings/DefaultKeyBinding.dict
(If you have already messed with key bindings, this file might already be present.)
2. Copy and paste this code into the file:
{
"\UF729" = "moveToBeginningOfLine:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
"\UF72B" = "moveToEndOfLine:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
"\UF72C" = "pageUp:";
"\UF72D" = "pageDown:";
}
3. Put your junk in that box (err, save DefaultKeyBinding.dict)
4. Open that box (err, close and reopen any applications to take affect)
That’s it!
Disclaimer:
- I am a Mac, Windows, and Linux user
- On the whole, Apple is usually pretty good about this crap.
Thanks for the great tip! I’ve been using DoubleCommand for a while to make home and end work properly:
http://doublecommand.sourceforge.net/
I acutally now use a combination of DoubleCommand and the DEfaultKeyBindings trick above (using keybindings just for the pgup/pgdown behavior)
The key setting in DoubleCommand is “PC style home and end keys”. This little plugin is also indispensable if you use a windows style keyboard (I use an MS natural KB) and still want to have option/command in the right places.
I use Eclipse as my main IDE, and since it’s not a Cocoa app it won’t honor the key bindings. However, it already has the sensible behavior for page up and page down, so all you have to modify to make Eclipse work well is the home and end keys. By setting the home and end keys in DoubleCommand, and mapping pgup/pgdown in the default keybindings, you make the home and end key work properly everywhere, and pgup/pgdown work correctly in cocoa apps.
I’m a new Mac’r… I’m on 10.5.x and this didn’t work on Terminal. bummer..
There is an option in preferences to remap the home key, but you can only remap it to a keystroke, not BeginningofLine.. I tried setting it to Ctl-A, but I use screen from time to time and the default binding for screen control is Ctl-A..
This is certainly one of the more frustrating things about OSX..
Thank you so much- this has really been driving me crazy about our new Mac!
Thank you so so much! This has always driven me crazy and as a coder – I’m using those keys constantly when programming. This was always my number one complaint about Macs. I never dreamed there would be a solution this easy! Thanks SO much!
Hey, thanks for this tip. I have always been annoyed by this and finally after five years decided to research it on Google. Great tip, thanks.
thanks for writing this, i’m a linux user working on a mac and this home/end behavior has been driving me fucking crazy.
also:
* i really wish osx would maximize windows to take up the full screen.
* i really wish i could activate windows by hovering over them.
* would be cool if if the osx clock would show date and time, not just day of week and time.
* how about another mouse button instead of a stumpy mouse and cereal box decoder ring?
i’ll stop… but my list goes on.
anyhow, thanks again for helping me fix this major pain point!
Worked perfectly. I agree 100% with your sentiments…
DoubleCommand does this well. You know what else is driving me crazy? The fact that when I plug in my Logitech keyboard, the Cmd and Option keys get switched!!! WTF.
So now, the start-key and is the cmd key (even though, on the keyboard itself, the icon shows “alt option” as well as the windows icon), and the Windows “Alt” key is now the “alt option” key, even though it’s labeled with the “Apple” and the “Command” icons.
But anyway, DoubleCommand fixes all that even though I have to undo my changes every time I take my laptop with me. ARGH!!!