Page MenuHomePhabricator

Mention hotkeys in tooltips in Favourite Templates
Open, Needs TriagePublicFeature

Description

Feature summary I would like to see keyboard shortcuts displayed in tooltips throughout the Favourite Templates interface, including the hotkey to open the dialog and the hotkeys available within the dialog.

Use case(s): When using the Favourite Templates feature I discovered that I can use Escape to close the dialog, and Ctrl-Enter to insert the templates (in some cases, see T399293. The underlying problem is that keyboard shortcuts exist but are not discoverable through the interface, forcing users to stumble upon them accidentally.

Benefits Improved discoverability of keyboard shortcuts would make the interface more accessible and efficient for power users. Users could learn shortcuts organically through normal usage rather than having to consult documentation. This follows standard UI conventions where shortcuts are displayed alongside their corresponding actions, improving the overall user experience. Using the mouse is difficult for some people for various reasons, and we shouldn't force people to switch from keyboard to mouse and back unnecessarily.

So if I hover over the Favourite Templates button in the editor I want to see:
"Favourite Template (Ctrl-L)" or whatever the hotkey actually is, I haven't found it yet if any exists.
When hovering over the close dialog button I want to see "Close (Escape)"
When hovering over the insert template button I want to see "Insert (Ctrl-Enter)"

Event Timeline

Polygnotus renamed this task from Mention hotkeys in tooltips to Mention hotkeys in tooltips in Favourite Templates.Jul 11 2025, 11:11 AM
Polygnotus updated the task description. (Show Details)

Implementing this would be trivial, because you're using ooui for your buttons and so all you need to do is tell it about an accesskey in the widget config.

You would need to switch from OO.ui.ButtonInputWidget to a plain OO.ui.ButtonWidget` because the former doesn't have AccessKeyedElement mixed in for some reason... but you're not using this in the context of an HTML form, so you don't need to be using ButtonInputWidget anyway.

"Favourite Template (Ctrl-L)" or whatever the hotkey actually is, I haven't found it yet if any exists.

None exists yet.

The main reason we've not added an accesskey is that it's hard to decide what it should be! There's an up-to-date list at https://www.mediawiki.org/wiki/Manual:Access_keys of the currently assigned accesskeys. Suggestions welcome!

So if I hover over the Favourite Templates button in the editor I want to see

I'm assuming this means on the button after selecting a template, as in on the template parameters' page? (And the same could be used on the template pages.) Because it's not possible to have an accesskey on all the favourite buttons in the search results or favourites list.

@Samwilson It would be really cool if I could add an accesskey to a particular button in JS. Do you happen to know how I would achieve that?

So for example, let's say I want Ctrl+L to open the Favourite Templates dialog box.

I'm assuming this means on the button after selecting a template

Here is a screenshot that shows what I mean, I added the "Ctrl-L" bit:

screenshot hover.png (175×493 px, 23 KB)

You can't see the mouse cursor for boring technical reasons but imagine that there is one next to the tooltip.

The buttons in the WikiEditor toolbar are OOUI buttons, so you just need to pass in accessKey when creating them. E.g. this patch would automate it: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikiEditor/+/1172895

If you wanted to do it after-the-fact because you're doing it in a userscript, it'd actually be a bit of a pain because only some of the buttons are set up as ButtonWidgets, and others are ToggleButtonWidgets which (for some reason) don't have accessKey mixed in -- but e.g. here's how to add one to the reference button: $('.tool[rel=reference]').data('ooui').setAccessKey('d')

Technically you can also just stick an accesskey attribute onto the appropriate element, but it wouldn't give you the effect on the title, and there's some issues with the focus that'd need to be addressed as well...

There's a difference between accesskeys (browser-based) and the opt- or ctrl- based ones such as ctrl-K to insert a new link. The latter are provided by VE and WikiEditor and can sometimes clash with web browser shortcuts. For example, ctrl-L selects the browser's address bar, and ctrl-M mutes the current tab or in VE removes formatting from the current selection.

Should we use L as the key, then? As far as I can see we don't have a registry of non-accesskey keys. We'd want to have it be the same in VE and WikiEditor.

I think ctrl-E might be a good alternative. It focuses the address bar in Chrome I think, but not in Edge or Firefox (whereas ctrl-L does that for all of them).

On macs cmd+E is "use selection for find" as a standard system-level shortcut. (But on macs we've already got conflicts -- WikiEditor does cmd+, for subscript, which is the absolute system shortcut for "open application settings".)

On macs cmd+E is "use selection for find" as a standard system-level shortcut. (But on macs we've already got conflicts -- WikiEditor does cmd+, for subscript, which is the absolute system shortcut for "open application settings".)

Yes, Command + [,] so thus in Safari it opens the Settings for the browser, but surprisingly in Chrome when the cursor is placed in the active editing window the shortcut works! (See related T400569 for the same keyboard shortcut conflict in VisualEditor.)

The { accesskey isn't currently used by any extensions or core, as far as I can see. That's sort of similar to ) which is used to reload the realtime preview.