1

So Microsoft released a free preview of Office for Mac, and it is pretty sweet.

One of my biggest problem when using Excel on a mac has always been that the most popular/frequent shortcut (F2 -> edit cell) was not available on macs (there was a default replacement, cmd-T I think, but not half as handy as F2).

Now F2 is here in the preview, great! But one still has to either press the Fn key, or switch the whole Fn key row (link from Apple page). Hence the question:

Is there a way to either:

  • selectively only switch the F2 key, or
  • switch the Fn key row automatically when opening Excel?
  • The equivalent of F2 on Office 2011 is Control-U. Given the "hard coding" of the Fn key, it might be just as annoying to press :-) – bjb Mar 11 '15 at 20:24
  • Ctrl-U is just unbearable, if only because it requires both hands. When auditing large files, one quite often repeatedly press F2-arrows to quick-check formulas. Anything else than a single keystroke does not work. And years of habits from WinXL are hard to change (especially when using both win and mac) – Alexandre Halm Mar 11 '15 at 20:28
  • And why the downvote ? – Alexandre Halm Mar 22 '15 at 19:34
2

I think the best way to achieve this is to install a keyboard mapper program. I use Karabiner. Once installed (might need a reboot?) you'll then see a menu bar icon that looks like a rounded square probably with the word 'Default' next to it; it is suggesting you're using the default mapping profile. Click on it and select 'Preferences' to access Karabiner's prefs applet so you can edit the private.xml file and add in the mapping below. You should be able to find a button for "Open private.xml" under the "Misc & Uninstall" tab of the preferences window.

Put this into your private.xml file:

<?xml version="1.0"?>
<root>

  <!-- ============================================================ -->
  <!-- Make F2 send as Ctrl-U for formula editing -->

  <appdef>
    <appname>Excel</appname>
    <equal>com.microsoft.Excel</equal>
  </appdef>

  <item>
    <name>F2 becomes Ctrl-U in Excel</name>
    <identifier>private.map_F2_to_ctrlU</identifier>
    <only>Excel</only>
    <autogen>__KeyToKey__ KeyCode::F2, KeyCode::U, ModifierFlag::CONTROL_L</autogen>
  </item>
</root>

That will now make it that when you hit F2, it will send to Excel the Ctrl-U sequence instead. Whatever F2 was doing before will no longer work, but it appears to be some kind of cut-and-paste.

Note that I am doing this on a wired apple extended keyboard (from a Mac Pro) where F2 doesn't require Fn (the alternate functions like volume do), so I don't know what the non-numeric keypad or laptop keyboards will do, but perhaps you'll have to add either KeyCode::FN or ModifierFlag::FN to the left side of that mapping if it doesn't work right away. Then again, the Fn behavior might be a keyboard preference- I don't recall off the top of my head.

It is worth pointing out that in the mapping file I created for this, I defined it in a way that this mapping will only be valid for the Excel application, it won't do it for any other application.

The only other thing you might need to do in the preferences window is under the "Change Key" tab, there will now be a checkbox for "F2 becomes Ctrl-U in Excel" which will need to be checked.

Let me know if that works. FWIW, I've used Karabiner for a few years now as a way to map the Right-Option key as a Windows Menu/Context key when running under Citrix Receiver (remote login to work PC) and it has worked well for me and updates have been painless.

  • Looks interesting, thanks. I actually use excel on a MBA, where F2 s switched on/off by the Fn key (MS has wisely moved the ^U shortcut to F2 but it is obliterated by Fn). Will explore possibilities though. – Alexandre Halm Mar 15 '15 at 11:13
  • @AlexH., in the Karabiner package there is a tool to display what key sequence is being pressed; this is how you can determine the names for the mappings. I think it might be under the "misc" tab with some name like inspector or event viewer. You could see what key it reports when you hit the F2 key without the Fn key and modify my mapping file to use that instead. – bjb Mar 16 '15 at 15:59
1

Unfortunately, the Fn key is interpreted before it even leaves the keyboard, so there is no way to 'fake it' later.

I haven't seen that version of Office yet, but… if there is a menu item for the function, you should be able to replace it using System Prefs > Keyboard > Shortcuts / App Shortcuts.
Hit the + button under the right-hand box, dial in the appropriate app, type the menu name & add any key combo you wish.

Edit

On second thoughts, unless Microsoft have stopped ignoring the Mac toolbox guidelines, that may not be possible…

See Create or delete a keyboard shortcut for the delightfully non-standard way MS has chosen to implement this functionality.

Create a keyboard shortcut for a task

  1. On the Tools menu, click Customize Keyboard.

  2. In the Categories list, click a menu name.

  3. In the list next to Categories, click the task that you want to assign a keyboard shortcut to.
    Any keyboard shortcuts that are currently assigned to the selected task appear in the Current keys box.
    TIP If you prefer to use a different keyboard shortcut, add another shortcut to the list, and then use it instead.

  4. In the Press new shortcut key box, type a key combination that includes at least one modifier key (COMMAND , CONTROL , OPTION , SHIFT ) and an additional key, such as COMMAND+ F11 .
    If you type a keyboard shortcut that is already assigned, the action assigned to that key combination appears next to Currently assigned to.

  5. Click Add.

NOTES

  • To cancel the keyboard shortcut assignment, press ESC .

  • Keyboard shortcut descriptions refer to the U.S. keyboard layout. Keys on other keyboard layouts might not correspond to the keys on a U.S. keyboard. Keyboard shortcuts for laptop computers might also differ.


Edit
I found this Applescript to toggle the F-Key state…

tell application "System Preferences"
    set current pane to pane "com.apple.preference.keyboard"
end tell


tell application "System Events"
    if UI elements enabled then
        tell tab group 1 of window "Keyboard" of process "System Preferences"
            click checkbox "Use all F1, F2, etc. keys as standard function keys"
        end tell
    else
        tell application "System Preferences"
            set current pane ¬
                to pane "com.apple.preference.universalaccess"
            display dialog ¬
                "UI element scripting is not enabled. Check \"Enable access for assistive devices\""
        end tell
    end if
end tell

tell application "System Preferences"
    quit
end tell

Source MacRumours
Post #12 has a much more comprehensive automated solution, but is too complex to post here.

  • thanks - the Customise keyboard menu item is not here anymore (or yet, the preview is probably not final). I'll try your first suggestion but I think the "edit cell" function has no name (I'm looking for it). – Alexandre Halm Mar 11 '15 at 20:11
  • Welcome - I sincerely hope they have actually used the standard Mac toolbox method for this new version - life becomes so much easier when you already know how to achieve something like this, without needing an entire kb article on 'how we do it differently in Redmond' ;) My key point, unfortunately, is that unless they provide some method to customise, there's no way to 'fake' a Fn key :( – Tetsujin Mar 11 '15 at 20:13
  • actually i'm now pretty sure that "F2" (which switches in/out of edit mode) is not in the menus (probably because it's so "basic"). Also I may have been unclear in my question: the shortcut actually exists now, it is F2. But there still is the Fn interference (you have to either press Fn+F2 every time - nope, or switch the whole Fn row from System prefs > Keyboard. Latter is doable but I'd rather not change years-old automatisms just for XL (and I use volume up/down quite often). – Alexandre Halm Mar 11 '15 at 20:17
  • For sure - hence my original idea of simply doing a substitution… which I afterwards realised wasn't going to be easy on MS software – Tetsujin Mar 11 '15 at 20:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .