Saturday, August 16, 2008

For Windows Users: Remapping the Home and End Keys to Emulate Windows Behavior

One of the first annoyances I discovered in switching from Windows to OS X was that the Home and End keys did not behave like I expected. In fact, they operate differently than in any other operating system I have ever used.

Normally if you hit the home or the end key it takes you to the beginning or the end of a line of text, text box, whatever. In OS X, the home and end keys take you to the top and bottom of a page.

The good news is that the same beginning/end functionality can be replicated by using the up and down arrows in OS X. The bad news is there is just no way I am going to be able to train myself to stop using home and end, especially when I am so used to using these keys for software development or word processing in Windows, so I had to come up with a solution.

It turns out that the solution is a two-step process for Mac users who are running Firefox, and a one-step process otherwise.

Step 1: Changing the Default Home and End Key Behaviors in OSX

Reference: evansweb.info | mac os x home / end keys
  1. Open a Terminal (Applications > Utilities > Terminal)
  2. Change the directory to Library (type: cd Library)
  3. Create the KeyBindings directory if it does not exist (type: mkdir KeyBindings)
  4. Change the directory to KeyBindings (type: cd KeyBindings)
  5. Run Pico (type: pico)
  6. Paste the following text--including the curly brackets--into Pico (Command+V to paste)
  7. {
    /* Remap Home / End to be correct :-) */
    "\UF729" = "moveToBeginningOfLine:";
    "\UF72B" = "moveToEndOfLine:";
    "$\UF729" = "moveToBeginningOfLineAndModifySelection:";
    "$\UF72B" = "moveToEndOfLineAndModifySelection:";
    }
  8. Save the file (Control+O)
  9. Name the file: DefaultKeyBinding.dict
  10. Exit Pico (Control+X)
  11. Log out of OS X, and log back in
Step 2: Changing the Default Home and End Key Behaviors in Firefox for OS X

Reference: Mac OS X Hints | Change Home/End behavior in Firefox and Thunderbird
  1. Jar extract the contents of /Applications » Firefox.app » [Control-click and show package contents] » Contents » MacOS » chrome » toolkit.jar into a temporary directory. Do this by moving toolkit.jar to your Desktop, opening a terminal window (Applications » Utilities » Terminal) and changing directories to your desktop (cd /Users/[You]/Desktop). Then extract the archive with this command: jar xf toolkit.jar.
  2. Replace the file content » global » platformHTMLBindings.xml with this one.
  3. Recreate the archive (jar cvf toolkit.jar content/) and replace the original toolkit.jar in the Firefox "chrome" directory above with the new one on your Desktop.
  4. Quit and restart Firefox

No comments: