Manual:Access keys
This page is currently a draft.
|
Access keys or keyboard shortcuts are defined for many actions in MediaWiki. This page documents all access keys in use, and details the ways in which developers can add them to MediaWiki core and extensions. End user help is at Help:Keyboard shortcuts .
Access keys are invoked with different modifier keys on different operating systems and web browsers. The Wikipedia:Access key page lists all combinations. MediaWiki will add tooltips where it can to help users discover what access keys are available for a given action (including platform-specific modifiers).
Defining an access key
[edit]Defining an access key is usually done via the accesskey=""
HTML attribute, and in some cases (e.g. in VisualEditor) is done with custom keypress handling.
The key used should not be hard-coded, but should be added as a system message. The message should start with accesskey-extname-
and its message documentation in qqq.json
should include the {{doc-accesskey}}
template from Translatewiki.net. Acccess key messages should also be listed in TranslateWiki's groups/MediaWiki/MediaWiki.yaml file (for example, Gerrit change 780284).
All access keys should be recorded on this page (see below), to make it easier for developers to choose new available access keys.
JavaScript
[edit]To create a button with an access key the following code could be used:
var myButton = new OO.ui.ButtonWidget( {
label: mw.msg( 'myext-myaction' ),
accessKey: mw.msg( 'accesskey-myext-myaction' ),
title: mw.msg( 'myext-myaction-title' )
} );
Note that when using OOUI, it's worth adding a title to any AccessKeyedElement because this results in the access key be appended to the title/tooltip and so is more discoverable by users.
PHP
[edit]The Linker::tooltipAndAccesskeyAttribs()
method should be used when constructing links with access keys. For example:
"accesskey-myext-myaction": "[[:Template:Doc-accesskey]]",
"tooltip-myext-myaction": "Tooltip for my action",
"myext-myaction": "Link text for my action",
"accesskey-myext-myaction": "a",
"tooltip-myext-myaction": "This is my action",
"myext-myaction": "My Action",
$link = \Html::element(
'a',
\Linker::tooltipAndAccesskeyAttribs( 'myext-myaction' ),
wfMessage( 'myext-myaction' )
);
This will result in the following HTML:
<a title="This is my action [a]" accesskey="a">My Action</a>"
In JavaScript-enabled browsers, the [a]
will be dynamically updated (to e.g. [Ctrl-Shift-a]
) by updateTooltipAccessKeys() to include the correct modifier keys depending on the user's browser and operating system.
MediaWiki core
[edit]Message | Access key | Usage |
---|---|---|
accesskey-pt-userpage | . | Codesearch |
accesskey-pt-anonuserpage | . | Codesearch |
accesskey-pt-mytalk | n | Codesearch |
accesskey-pt-anontalk | n | Codesearch |
accesskey-pt-preferences | Codesearch | |
accesskey-pt-watchlist | l | Codesearch |
accesskey-pt-mycontris | y | Codesearch |
accesskey-pt-anoncontribs | y | Codesearch |
accesskey-pt-login | o | Codesearch |
accesskey-pt-login-private | o | Codesearch |
accesskey-pt-logout | Codesearch | |
accesskey-pt-createaccount | Codesearch | |
accesskey-ca-view | Codesearch | |
accesskey-ca-talk | t | Codesearch |
accesskey-ca-edit | e | Codesearch |
accesskey-ca-addsection | + | Codesearch |
accesskey-ca-viewsource | e | Codesearch |
accesskey-ca-history | h | Codesearch |
accesskey-ca-protect | = | Codesearch |
accesskey-ca-unprotect | = | Codesearch |
accesskey-ca-delete | d | Codesearch |
accesskey-ca-undelete | d | Codesearch |
accesskey-ca-move | m | Codesearch |
accesskey-ca-watch | w | Codesearch |
accesskey-ca-unwatch | w | Codesearch |
accesskey-search | f | Codesearch |
accesskey-search-go | Codesearch | |
accesskey-search-fulltext | Codesearch | |
accesskey-p-logo | Codesearch | |
accesskey-n-help-mediawiki | Codesearch | |
accesskey-n-mainpage | z | Codesearch |
accesskey-n-mainpage-description | z | Codesearch |
accesskey-n-portal | Codesearch | |
accesskey-n-currentevents | Codesearch | |
accesskey-n-recentchanges | r | Codesearch |
accesskey-n-randompage | x | Codesearch |
accesskey-n-help | Codesearch | |
accesskey-t-whatlinkshere | j | Codesearch |
accesskey-t-recentchangeslinked | k | Codesearch |
accesskey-feed-rss | Codesearch | |
accesskey-feed-atom | Codesearch | |
accesskey-t-contributions | Codesearch | |
accesskey-t-emailuser | Codesearch | |
accesskey-t-info | Codesearch | |
accesskey-t-permalink | Codesearch | |
accesskey-t-print | p | Codesearch |
accesskey-t-upload | u | Codesearch |
accesskey-t-specialpages | q | Codesearch |
accesskey-ca-nstab | c | Codesearch |
accesskey-ca-nstab-main | c | Codesearch |
accesskey-ca-nstab-user | c | Codesearch |
accesskey-ca-nstab-media | c | Codesearch |
accesskey-ca-nstab-special | Codesearch | |
accesskey-ca-nstab-project | c | Codesearch |
accesskey-ca-nstab-image | c | Codesearch |
accesskey-ca-nstab-mediawiki | c | Codesearch |
accesskey-ca-nstab-template | c | Codesearch |
accesskey-ca-nstab-help | c | Codesearch |
accesskey-ca-nstab-category | c | Codesearch |
accesskey-minoredit | i | Codesearch |
accesskey-save | s | Codesearch |
accesskey-publish | s | Codesearch |
accesskey-preview | p | Codesearch |
accesskey-diff | v | Codesearch |
accesskey-compareselectedversions | v | Codesearch |
accesskey-watch | w | Codesearch |
accesskey-watchlist-expiry | Codesearch | |
accesskey-upload | s | Codesearch |
accesskey-preferences-save | s | Codesearch |
accesskey-summary | b | Codesearch |
accesskey-userrights-set | s | Codesearch |
accesskey-blockip-block | s | Codesearch |
accesskey-export | s | Codesearch |
accesskey-import | s | Codesearch |
accesskey-watchlistedit-normal-submit | s | Codesearch |
accesskey-watchlistedit-raw-submit | s | Codesearch |
Extensions
[edit]Extension | Message name | Access key | Usages |
---|---|---|---|
CiteThisPage | accesskey-citethispage | Codesearch | |
Drafts | accesskey-drafts-save | g | Codesearch |
EducationProgram | accesskey-ep-form-save | s | Codesearch |
EducationProgram | accesskey-ep-edit-institution | e | Codesearch |
EducationProgram | accesskey-ep-edit-course | e | Codesearch |
EducationProgram | accesskey-ep-summary | b | Codesearch |
EducationProgram | accesskey-ep-minor | i | Codesearch |
MediaUploader | accesskey-save-upload-campaign | s | Codesearch |
MediaUploader | accesskey-cancel-upload-campaign | c | Codesearch |
PageForms | accesskey-ca-formedit | & | Codesearch |
UploadWizard | accesskey-save-upload-campaign | s | Codesearch |
UploadWizard | accesskey-cancel-upload-campaign | c | Codesearch |
WatchSubpages | accesskey-watchsubpages-submit | s | Codesearch |
WikiEditor | accesskey-wikieditor-realtimepreview | ) | Codesearch |
Wikibase | accesskey-t-wikibase | g | Codesearch |
FlaggedRevs | accesskey-ca-current | v | Codesearch |
FlaggedRevs | accesskey-ca-stable | c | Codesearch |
VisualEditor | accesskey-ca-editsource | e | Codesearch |
VisualEditor | accesskey-ca-ve-edit | v | Codesearch |
ListTransclusions | accesskey-t-listtransclusions | Codesearch |
See also
[edit]- Wikipedia:Access key — General information, including how to use them on different browsers.
- TranslateWiki:Template:Doc-accesskey — All access keys should use this template in their qqq.json documentation.