Home & End: Key Bindings in OS X

September 20, 2008 - Reading time: 3 minutes

One thing has bothered me about Macs: the key bindings. Specifically, I was annoyed that the home, end, page up, and page down keys don’t work like they “normally” do on a Windows machine. I found myself having to use the awkward “Apple + arrow” combinations to advance to the front or end of a line (home and end normally send the cursor to the beginning or end of the document, not the line). This is awkward at best, and it was made even more awkward when you consider the layout of my Kinesis keyboard (trippy, I know).

Even if you don’t have a tripped out keyboard, it makes a lot of sense to have “normal” functionality for your home and end keys AND have the ctrl key functionality within reach when you’re working in the Terminal; a lot of Unix/Linux/Bash stuff is mapped to the ctrl key (e.g. ctrl + c to exit a bash program).

OS X has full flexibility on how you handle your key bindings (woot). All you have to do is create a file that remaps the desired keys. This is best done on a per-user basis, so you create a new file in the user’s Library. Create the directory and file (if necessary), and add the following:


/* This adds "normal" home, end, page up, page down functionality */
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
{
"\UF729" = "moveToBeginningOfLine:";
"^\UF729" = "moveToBeginningOfDocument:";
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
"^$\UF729" = "moveToBeginningOfDocumentAndModifySelection:";
"\UF72B" = "moveToEndOfLine:";
"^\UF72B" = "moveToEndOfDocument:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
}

Once you’ve made the changes, log out your user and log back in (you don’t need to reboot). Try opening up a text editor and navigate around a document using the home and end keys. It’s great.

Because of my keyboard layout, I also want to move my command key (i.e. Apple key) functionality over to the ctrl key — this doesn’t make much sense on a standard keyboard (where your pinky reflex starts going carpal tunnel), but it makes a lot of sense on a Kinesis keyboard where the ctrl key is directly next to your thumb but the Apple key is a bit of a reach.

-- Everett Griffiths

About

Tech tips, reviews, tutorials, occasional rants.

Seldom updated.