24

I'm used to the F5 key being the Refresh command (as it is in Windows OS for every browser I've ever used there) and not Command-R (which takes two fingers). On Mac OS X Lion, how can I assign the F5 key to be refresh inside Chrome?

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
WilliamKF
  • 8,058

5 Answers5

55

You can change the shortcuts of menu items in System Preferences, but you can't assign multiple shortcuts to them.

You could also assign a shortcut to a script like this:

try
    tell application "Google Chrome" to reload tab 1 of window 1
end try

1) Go to Preferences > Keyboard > Keyboard Shortcuts.

2) Select "Application Shortcuts" from the left menu.

3) Click "+".

4) Fill out the form like so: Application Google Chrome, Menu Title: Reload This Page, Keyboard Shortcut F5.

5) Click "Add".

Lri
  • 42,502
  • 8
  • 126
  • 159
7

Looks like they moved the location of the shortcut at least since the previous commenter posted.

I'm using El Capitan 10.11.13 and for me it is in System Preferences > Keyboard Shortcuts > App Shortcuts

Screenshot

fixer1234
  • 28,064
Crhistian
  • 171
2

Many years later. And now, with Karabiner-Elements, the same can be accomplished with the following code:

{
    "description": "F5 => Cmd+R (Reload, only in browsers)",
    "manipulators": [
        {
            "conditions": [
                {
                    "bundle_identifiers": [
                        "^org\\.mozilla\\.firefox$",
                        "^org\\.mozilla\\.firefoxdeveloperedition$",
                        "^org\\.mozilla\\.nightly$",
                        "^com\\.microsoft\\.edgemac$",
                        "^com\\.google\\.Chrome$",
                        "^com\\.brave\\.Browser$",
                        "^com\\.apple\\.Safari$"
                    ],
                    "type": "frontmost_application_if"
                }
            ],
            "from": {
                "key_code": "f5"
            },
            "to": [
                {
                    "key_code": "r",
                    "modifiers": [
                        "left_command"
                    ]
                }
            ],
            "type": "basic"
        }
    ]
}

First, go to "Function Keys" and set F5 -> F5.

Then, head to "Complex Modifications" and select "Add your own rule". Add the above code (or, if you have already added something into the field you want to keep, integrate the above code into your existing ruleset). Save, and you're in business!

The starting point for this, which no longer worked with the current Karabiner-Elements, was "Windows-ify Key Mappings to Mac OS," found in the web archive for Karabiner-Elements rules.

Ville
  • 3,492
  • 3
  • 24
  • 20
1

F5 will refresh the page in Firefox but it's not currently enabled in Chrome for some reason. Using App Shortcuts in Keyboard preferences will get F5 to work, but it disables Command-R as a refresh shortcut. This wasn't a good solution for me so I removed the F5 shortcut definition. It had bugged me for months and I've finally solved it with Karabiner and help from the accepted answer:

<vkopenurldef>
  <name>KeyCode::VK_OPEN_URL_SHELL_chrome_refresh</name>
  <url type="shell">osascript -e 'tell application "Google Chrome" to reload active tab of window 1'</url>
</vkopenurldef>

<item>
  <name>Refresh Chrome Page With F5</name>
  <appendix>Enables the F5 key to refresh the page in Google Chrome.</appendix>
  <identifier>private.function_five</identifier>
  <only>GOOGLE_CHROME</only>
  <autogen>__KeyToKey__ KeyCode::F5, KeyCode::VK_OPEN_URL_SHELL_chrome_refresh</autogen>
</item>

Open Karabiner's preferences, then on the Misc & Uninstall tab click the Open private.xml button. It'll open Finder and you can open the file from there in your favorite text editor. Enter the code above between the <root> tags and save the file. Go back to the Karabiner preferences and switch to the Change Key tab and at the top right, click the Reload XML button. The new option should appear at the top and all you have to do is enable it.

Details:

  • The <vkopenurldef> element defines an applescript command that can be bound to another key. This command tells Chrome to reload the active tab in window 1 (window 1 appears to be the active window).
  • The <item> element binds the new command to a physical key - in this case F5.

Official instructions on the private.xml file can be found here: https://pqrs.org/osx/karabiner/document.html.en#privatexml

Phunt
  • 11
1

If your on OS X that has Notification Center such as El Capitan follow the answer of Crhistian and then go to Mission Control in Keyboard Shortcuts and disable the F5 shortcut for Show Notification Center (and assign an alternative if you wish). BTW, this will disable the CTRL + R shortcut.

Jono
  • 111