컴퓨터/Mac Life

Mac OS X Home and End Keys

Subi Lee 2010. 8. 11.
반응형

Update: Now you can skip all these instructions and just download my KeyFixerapplication 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 :)


http://www.starryhope.com/tech/2006/mac-os-x-home-and-end-keys/


반응형

댓글