Add Option+Cmd+U as an alternate keyboard shortcut for "View Source" on macOS like Safari and Chrome

RESOLVED FIXED in Firefox 57

Status

()

enhancement
RESOLVED FIXED
2 years ago
3 months ago

People

(Reporter: cpeterson, Assigned: cpeterson)

Tracking

51 Branch
mozilla57
x86_64
macOS
Points:
---

Firefox Tracking Flags

(firefox-esr52 wontfix, firefox55 wontfix, firefox56 wontfix, firefox57 fixed)

Details

(Whiteboard: parity-chrome,parity-safari)

Attachments

(1 attachment)

Assignee

Description

2 years ago
We should add Option+Cmd+U as an alternate keyboard shortcut for "View Source" on macOS so Safari and Chrome web developers don't need to retrain their muscle memory.

Chrome and IE/Edge on Windows: Ctrl+U
Firefox on Windows: Ctrl+U

Safari and Chrome on macOS: Option+Cmd+U
Firefox on macOS: Cmd+U

This keyboard shortcut alias was a feature request from Twitter:

https://twitter.com/justnorris/status/905377487722565632

Below are links to lists of Chrome's keyboard shortcuts. There are other keyboard shortcuts that differ between Firefox, Chrome, and Safari.

https://support.google.com/chrome/answer/157179?hl=en

https://developers.google.com/web/tools/chrome-devtools/shortcuts
Assignee

Comment 2

2 years ago
Joe and Markus, I'm not sure who the appropriate reviewer should be. The keyboard shortcut for "View Source" falls into a limbo between DevTools, Mac widget, and UX. <:)
Flags: needinfo?(mstange)
I'd put the responsibility with browser frontend people.
As for this change, you have my approval from the Mac widget side, but I don't think my side is very relevant.
Flags: needinfo?(mstange)
Gijs, can you suggest an appropriate reviewer?
Flags: needinfo?(gijskruitbosch+bugs)

Updated

2 years ago
Attachment #8906877 - Flags: review?(jwalker) → review?(gijskruitbosch+bugs)

Comment 5

2 years ago
mozreview-review
Comment on attachment 8906877 [details]
Bug 1398988 - Add Option+Command+U as an alternate keyboard shortcut for "View Source" on macOS like Safari and Chrome.

https://reviewboard.mozilla.org/r/178610/#review183718

I think I can review this, given how old/browser-y view source is and the location of the code change. I'm sure Joe will yell at me if he disagrees. :-)

This is effectively an r+ for making this change. However, we really need to use a separate key l10n string. There should probably also be a localization comment next to the string pointing to this bug and explaining why we have a second string (ie safari/chrome parity), so that other locales can, uh, actually do the same thing as French/Chinese/Canadian Safari/Chrome localizations (whatever that is - I'm not actually sure!). I'm erring on the side of clearing review rather than r+ mostly because it's so annoying to re-request review with mozreview if you wanted to do that. I promise a speedy r+ for an updated version that addresses the comments.

::: browser/base/content/browser-sets.inc:290
(Diff revision 1)
>      <key key="&reloadCmd.commandkey;" command="Browser:Reload" modifiers="accel" id="key_reload"/>
>      <key key="&reloadCmd.commandkey;" command="Browser:ReloadSkipCache" modifiers="accel,shift"/>
>      <key id="key_viewSource" key="&pageSourceCmd.commandkey;" command="View:PageSource" modifiers="accel"/>
> +#ifdef XP_MACOSX
> +    <!-- Also support Option+Cmd+U as alternate keyboard shortcut for "View Source" on macOS like Safari and Chrome. -->
> +    <key id="key_viewSource2" key="&pageSourceCmd.commandkey;" command="View:PageSource" modifiers="accel,alt"/>

Please duplicate the key l10n id, probably naming it something like "pageSourceCmd.macCommandKey" (based on the others in that style), and use that. We can't assume that locales other than English can reuse the same key for both the cmd-<foo> and cmd-alt-<foo> switch.
Attachment #8906877 - Flags: review?(gijskruitbosch+bugs)

Updated

2 years ago
Flags: needinfo?(gijskruitbosch+bugs)
Assignee

Comment 6

2 years ago
(In reply to :Gijs from comment #5)
> Please duplicate the key l10n id, probably naming it something like
> "pageSourceCmd.macCommandKey" (based on the others in that style), and use
> that. We can't assume that locales other than English can reuse the same key
> for both the cmd-<foo> and cmd-alt-<foo> switch.

Thanks, Gijs! I forgot that other locales might use different letters for their keyboard shortcuts. I added a localization comment and changed the `key_viewSource2` name to the more descriptive `key_viewSourceSafari`. This new patch is much nicer. :)
Comment hidden (mozreview-request)

Comment 8

2 years ago
mozreview-review
Comment on attachment 8906877 [details]
Bug 1398988 - Add Option+Command+U as an alternate keyboard shortcut for "View Source" on macOS like Safari and Chrome.

https://reviewboard.mozilla.org/r/178610/#review184250

LGTM, thanks!
Attachment #8906877 - Flags: review?(gijskruitbosch+bugs) → review+

Comment 9

2 years ago
Pushed by cpeterson@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8b15b56420ad
Add Option+Command+U as an alternate keyboard shortcut for "View Source" on macOS like Safari and Chrome. r=Gijs

Comment 10

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/8b15b56420ad
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
Component: Keyboard: Navigation → User events and focus handling
You need to log in before you can comment on or make changes to this bug.