Posted on

OSX Mapping Control F To Find

After using Windows for more than 20 years I have found the switch to OS/X to have been a move that should have happened years ago. I cannot count the thousands of hours of lost productivity. To be fair, it is likely a few hundred hours as OS/X was not a true alternative to the power of Windows until the latest OS/X iterations over the past 5 years. After spending more than EIGHT HOURS trying to get Minecraft working on a 3-year-old PC (windows updates, driver updates, incompatible graphics drivers for Java… the usual Windows debacle) I decided I will rarely-if-ever recommend ANYONE every buy a Windows PC from this point forward.

However the move to OS/X has not been completely pain free. I am heavily trained on Windows and Linux keyboard shortcuts. One of the BIGGEST FAILINGS of OS/X was their decision to create a proprietary keyboard system for OS/X. They introduced things like the command key and the “apple key” along the way when the rest of the OS world standardized on keyboard mappings using the more-than-adequate 100+ keys including control, alt, shift, and the thousands of combinations therein.

After 6 months of using OS/X I still find myself pressing things like control-SOMETHING to perform an action. Control (^) C for copy. ^f for find. ^x for cut. ^v for paste. To perpetuate the keyboard training, I use a Linux virtual machine in GUI mode for my daily WordPress development. Linux adopted the defacto standards of the industry in the early 80s and uses the same key presses defined by , not Microsoft, but IBM.

Today I find the control-key training to slow me down significantly when using native OS/X apps. I found a “fix” for mapping the edit operations fairly quickly. You can do so without using Karabiner (which causes some odd side effects). You can edit the DefaultKeyBinding.dict file in your Users directory on OS/X. Create or edit the file:
~/Library/KeyBindings/DefaultKeyBinding.dict

You can assign keys like this:

{
/* Remap Home / End to PC Edition */
"\UF729"  = "moveToBeginningOfLine:";                   /* Home         */
"\UF72B"  = "moveToEndOfLine:";                         /* End          */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:";       /* Shift + End  */

    "^x" = cut:;
    "^c" = copy:;
    "^v" = paste:;
}

That remaps the oft-used ^c, ^x, and ^v commands to their OS/X equivalents of Command (@) X, @-c, and @-v respectively.

But mapping ^f is a whole other kettle of fish. Mapping the action for find is NOT quite as simple. I tried mapping ^f to @f, which executes a “find action” in most OS/X apps. I tried using the action code “find:”, to no avail.

However there is an easy way to map ^f to find in most apps. MOST apps. Not OS/X Firefox, which appears to not like changing the default keyboard mapping utility. More on that later.

For most apps, let’s take Google Chrome as an example, you can change the ^f to be the find key by using OS/X System Preferences.

OSX Keyboard Shortcuts
OSX Keyboard Shortcuts interface.
  • Go to System Preferences
  • Select Keyboard
  • Select Shortcuts
  • Select App Shortcuts
  • Then click the + to add a new app shortcut.
  • Pick your app, Google Chrome in this case.
  • Now you need to find the EXACT menu text for the find command.  On Google Chrome it is “Find…”.  The … is important.
  • Press the Control-F key combination to set that as the new find command.
  • Exit the app, i.e. Google Chrome, if you had it running (which you did because you had to look at  the Find menu entry text).
  • Restart the app.
  • Your menu should now show the Find shortcut code is ^f
Chrome ^f as Find
Chrome ^f as Find

What about Firefox?   It turns out the mapping shows up but does not work.   The menu shows ^f is the new find key, but it does not activate.  I had to install the Customizable Shortcuts add-on for Firefox and set the find key to be ^f instead of modifier-F (the system-set default).     For some reason Firefox has hard-bound to the modifier key internally instead of using standard OS/X keyboard mapping system calls.   The menu rendering is apparently a separate piece of code.