Change the behavior of the home and end keys

Mac OS X Add comments

I found this helpful hint in the Slashdot comment area this evening and I wanted to pass it along. I would like to be able to give credit to the creator, but I don’t know his or her name. Whoever you are, thanks.

The home and end keys behave differently in Mac OS X than they do Windows. In Windows, to go to the beginning of a line, you press home, and to go to the end, you press end. In OS X, you go to the beginning of the line by pressing command-left arrow, and the end of the line with command-right arrow.

To change the Mac’s home and end keys to behave like Windows, create a text file named ~/Library/KeyBindings/DefaultKeyBinding.dict (if the folder doesn’t exist, go ahead and create it) and add these lines:

/* Home/End keys like Windows */
{
"\UF729" = "moveToBeginningOfLine:"; /* home */
"\UF72B" = "moveToEndOfLine:"; /* end */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* shift + home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* shift + end */
}

Logout and login, and the home and end keys will work like Windows.

These changes appear to work in any OS X GUI app, but they don’t seem to apply to the Terminal. For those of you who are unaware, you can jump to the beginning of a Terminal line using control-a, and the end by pressing control-e.

5 Responses to “Change the behavior of the home and end keys”

  1. Home sweet home at Mr Chuckles dot net Says:

    [...] In my continuing trend of hacking OSX to behave the way I want am accustomed to, I spent Monday night reclaiming my home and end keys. I knew I had seen this hack somewhere before, I just had to find it again. This comes courtesy of Aaron Adams, via The Tao of Mac: To change the Mac’s home and end keys to behave like Windows, create a text file named /Library/KeyBindings/DefaultKeyBinding.dict (if the folder doesn’t exist, go ahead and create it) and add these lines: [...]

  2. Home and End keys on the Mac » EverythingTech Says:

    [...] user and the Mac’s way of dealing with Home and End really bugs you, here’s a tip from Aaron Adams - To change the Mac’s home and end keys to behave like Windows, create a text file named [...]

  3. Le blog » Archive du blog » links for 2007-03-09 Says:

    [...] Change the behavior of the home and end keys Un petit tutorial pour que les touches “Home” et “End” fontionnent normallement sur mon Mac. (tags: documentation keyboard tutorial usability macosx) [...]

  4. mats Says:

    windows user: where do i store the file “/Library/KeyBindings/DefaultKeyBinding.dict” i create?

  5. Aaron Adams Says:

    The path “/Library/KeyBindings” means, the Library folder at the root of your drive (Macintosh HD) and a folder under that named KeyBindings. If KeyBindings does not exist, go ahead and create it.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in