Template:Key press/doc: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
(Undid revision 439408428 by Cybercobra (talk) Does not show in IE and Chrome.)
(Update interwikilink targets)
 
(34 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE. -->
{{Notice|It contains usage information, categories and other content that is not part of the original template page.|''NOTICE:'' This is a documentation subpage for [[:{{SUBJECTSPACE}}:{{BASEPAGENAME}}]]}}<br />
__NOTOC__


This is the {{tl|key press}} template, which can be used to illustrate keystrokes. Typographically it works best with examples that are separated from the normal flow of text, e.g. in table cells. It can also be used in lists (as in this page), but it may be a good idea to add an empty line between each list item, so the key borders won't overlap each other.
The <kbd style="font-size: 1.15em; font-weight: 800;"><nowiki>{{</nowiki>[[Template:Key press|Key press]]<nowiki>}}</nowiki></kbd> template can be used to visually illustrate keystrokes. Typographically, it works best with examples that are separated from the normal flow of text, e.g. in table cells. It can also be used in lists (as on this page), but it may be a good idea to add an empty line between each list item, so the key borders won't overlap each other.


Example:
Example:
:<code><nowiki>{{key press|A}}</nowiki></code> produces {{key press|A}}
:{{Tlx|Key press|A}} produces {{Key press|A}}
 
=== Keystroke combinations ===


== Keystroke combinations ==
To illustrate keystroke combinations, just use extra parameters:
To illustrate keystroke combinations, just use extra parameters:
:<code><nowiki>{{key press|Alt|P}}</nowiki></code> produces {{key press|Alt|P}}
:{{Tlx|Key press|Alt|P}} produces {{Key press|Alt|P}}
 
:<code><nowiki>{{key press|Ctrl|Alt|Del}}</nowiki></code> produces {{key press|Ctrl|Alt|Del}}
 
This template currently handles up to 5 key name parameters. If it gets too many key name parameters it reports the page into [[:Category:Wikipedia keypress template parameter needs fixing]]. This means we can easily find those pages and fix them, or we can discover if we need to make this template take more parameters.
 
When you feed several key names to this template, it adds a "+" with no spaces around. This means it won't line wrap. But when you show key combinations for instance in a table then that might cause too wide items. Then instead manually build the key combination with spaces around the "+" so it can line wrap. Like this:


:<code><nowiki>{{key press|Ctrl}} + {{key press|Alt}} + {{key press|Del}}</nowiki></code> produces {{key press|Ctrl}} + {{key press|Alt}} + {{key press|Del}}
:{{Tlx|Key press|Ctrl|Alt|Del}} produces {{Key press|Ctrl|Alt|Del}}


On the other hand, to illustrate Windows [[Alt code]]s you might want to use separate templates with no intervening punctuation or space. In most Windows systems in North America and Western Europe, for example, the [[plus-minus sign]] (±) can be entered by holding down the Alt key while typing <code>0177</code> (with the [[numeric keypad]]). This could be illustrated like this:
This template currently handles up to five (5) key name parameters; which should be more than enough to accomodate any possible '''simultaneous''' keystrokes.


:<code><nowiki>{{key press|Alt|0}}{{key press|1}}{{key press|7}}{{key press|7}}</nowiki></code> produces {{key press|Alt|0}}{{key press|1}}{{key press|7}}{{key press|7}}
When you feed several key names to this template, it adds a <code>+</code> with no surrounding whitespace. This means it can't line wrap, but when you show key combinations, for instance in a table, then that might cause overflow issues due to content being too wide for its container. The workaround in such instances is to manually build the key combination with spaces around the <code>+</code> so it can line wrap, like this:


=== Wikilinks ===
:{{Tlx|Key press|Ctrl}} + {{Tlx|Key press|Alt}} + {{Tlx|Key press|Del}} produces {{Key press|Ctrl}} + {{Key press|Alt}} + {{Key press|Del}}


If there is an article about the key you can [[WP:wikilink|wikilink]] the key's name like any other wiki text. Like this:
On the other hand, to illustrate Windows [[wikipedia:Alt code|Alt codes]], you might want to use separate templates with no intervening punctuation or whitespace. In most Windows systems in North America and Western Europe, for example, the [[wikipedia:Plus–minus sign|plus–minus sign]] (<code>±</code>) can be entered by holding down the Alt key while entering <code>0177</code> (with the [[wikipedia:Numeric keypad|numeric keypad]]). This could be illustrated as follows:
:<code><nowiki>{{key press|[[Alt key|Alt]]}}</nowiki></code> produces {{key press|[[Alt key|Alt]]}}


If you are wikilinking the keys, please ensure that you are piping to the correct page (e.g. <code><nowiki>[[Control key|Ctrl]]</nowiki></code> instead of <code><nowiki>[[Ctrl]]</nowiki></code>, which leads to a [[WP:Disambiguation page|disambiguation page]]).
:{{Tlx|Key press|Alt|0}}{{Tlx|Key press|1}}{{Tlx|Key press|7}}{{Tlx|Key press|7}} produces {{Key press|Alt|0}}{{Key press|1}}{{Key press|7}}{{Key press|7}}


=== Wiki characters ===
== Wikilinks ==
If there is an article about the key, you can wikilink the key's name just like any other wikitext, just like so:
:{{Tlx|Key press|&lsqb;&lsqb;wikipedia:Alt key&vert;Alt&rsqb;&rsqb;}} produces {{Key press|[[wikipedia:Alt key|Alt]]}}


Some wiki markup character, like the [[pipe symbol]], the [[semicolon]] and the [[equals sign]], need to be entered using the {{tl|!}}, {{tl|;}} and {{tl|{{=}}}} templates:
When you are wikilinking the keys, please ensure that you are piping to the correct page (e.g. <code><nowiki>[[wikipedia:Control key|Ctrl]]</nowiki></code> instead of <code><nowiki>[[wikipedia:Ctrl]]</nowiki></code>, which leads to a disambiguation page).


:<code><nowiki>{{key press|{{!}}}}</nowiki></tt> produces {{key press|{{!}}}}
== Wiki characters ==
Some wiki markup characters, like the [[wikipedia:Vertical bar|pipe symbol]], the [[wikipedia:Semicolon|semicolon]] and the [[wikipedia:Equals sign|equality sign]], need to be entered using the {{Tlx|!}}, {{Tlx|;}} and {{Tlx|&equals;}} templates:


:<code><nowiki>{{key press|{{;}}}}</nowiki></tt> produces {{key press|{{;}}}}
:{{Tlx|Key press|&lbrace;&lbrace;!&rbrace;&rbrace;}} produces {{Key press|{{!}}}}


:<code><nowiki>{{key press|{{=}}}}</nowiki></tt> produces {{key press|{{=}}}}
:{{Tlx|Key press|&lbrace;&lbrace;;&rbrace;&rbrace;}} produces {{Key press|{{;}}}}


However, if the characters are marked as wikilinks, they can be entered as such:
:{{Tlx|Key press|&lbrace;&lbrace;&equals;&rbrace;&rbrace;}} produces {{Key press|{{=}}}}


:<code><nowiki>{{key press|[[|]]}}</nowiki></code> produces {{key press|[[|]]}}


:<code><nowiki>{{key press|[[;]]}}</nowiki></code> produces {{key press|[[;]]}}
Alternately, {{Tlx|Key press|&lt;nowiki>|&lt;/nowiki>}} is also an option.


:<code><nowiki>{{key press|[[=]]}}</nowiki></code> produces {{key press|[[=]]}}
== Key symbols ==
Some key names have a fitting unicode character, and in those instances this template automatically adds such symbols to the following keys:


If you don't want to mark the characters as links, <code><nowiki>{{key press|&lt;nowiki>|&lt;/nowiki>}}</nowiki></code> is also an option.
:{{Tlx|Key press|Caps Lock}} produces {{Key press|Caps Lock}}


=== Key symbols ===
:{{Tlx|Key press|Shift}} produces {{Key press|Shift}}


Some key names have a fitting unicode character. This template automatically adds such "icons" to the following key names:
:{{Tlx|Key press|Enter}} produces {{Key press|Enter}}


:<code><nowiki>{{key press|Caps Lock}}</nowiki></code> produces {{key press|Caps Lock}}
:{{Tlx|Key press|Tab}} produces {{Key press|Tab}}


:<code><nowiki>{{key press|Shift}}</nowiki></code> produces {{key press|Shift}}
:{{Tlx|Key press|Backspace}} produces {{Key press|Backspace}}


:<code><nowiki>{{key press|Enter}}</nowiki></code> produces {{key press|Enter}}
:{{Tlx|Key press|Cmd}} produces {{Key press|Cmd}}


:<code><nowiki>{{key press|Tab}}</nowiki></code> produces {{key press|Tab}}
:{{Tlx|Key press|Opt}} produces {{Key press|Opt}}


:<code><nowiki>{{key press|Backspace}}</nowiki></code> produces {{key press|Backspace}}
:{{Tlx|Key press|Up}} produces {{Key press|Up}}


:<code><nowiki>{{key press|Cmd}}</nowiki></code> produces {{key press|Cmd}}
:{{Tlx|Key press|Down}} produces {{Key press|Down}}


:<code><nowiki>{{key press|Opt}}</nowiki></code> produces {{key press|Opt}}
:{{Tlx|Key press|Left}} produces {{Key press|Left}}


:<code><nowiki>{{key press|Up}}</nowiki></code> produces {{key press|Up}}
:{{Tlx|Key press|Right}} produces {{Key press|Right}}


:<code><nowiki>{{key press|Down}}</nowiki></code> produces {{key press|Down}}


:<code><nowiki>{{key press|Left}}</nowiki></code> produces {{key press|Left}}
There are no characters for the [[wikipedia:Windows key|Windows key]] and [[wikipedia:Menu key|Menu key]], so this template shows approximate characters for them in the following way:


:<code><nowiki>{{key press|Right}}</nowiki></code> produces {{key press|Right}}
:{{Tlx|Key press|Win}} produces {{Key press|Win}}


[[File:AltGr Win Menu Ctrl key.jpg|thumb|200px|Windows key and Menu key]]
:{{Tlx|Key press|Menu}} produces {{Key press|Menu}}
[[File:Ctl wndws alt.jpg|thumb|200px|Old-style Windows key]]


There are no characters for the [[Windows key]] and [[Menu key]]. Besides, the Windows logo is [[trademark]]ed. So this template shows approximate characters for them in the following way:
== Video games ==
Video game controllers often have specialized input labels that do not map quite as easily. The following are mappings for various game consoles and input features.


:<code><nowiki>{{key press|Win}}</nowiki></code> produces {{key press|Win}}
=== Directional input ===
The following should only be used when the input sequence uses something other than the primary input, or mixes input between directional devices.
:{{Tlx|Key press|l-down}} produces {{Key press|l-down}}
:{{Tlx|Key press|c-left}} produces {{Key press|c-left}}
:{{Tlx|Key press|r-up}} produces {{Key press|r-up}}


:<code><nowiki>{{key press|Menu}}</nowiki></code> produces {{key press|Menu}}
Stick specific diagonals are also supported:
{{clear}}


=== Technical details ===
:{{Tlx|Key press|l-nw}} produces {{Key press|l-nw}}
:{{Tlx|Key press|c-se}} produces {{Key press|c-se}}
:{{Tlx|Key press|r-ne}} produces {{Key press|r-ne}}


This template calls {{tl|key press/core}}, which holds the code that otherwise would be repeated several times in {{tl|key press}}, thus simplifying the code.
{{Clear}}


=== See also ===
== Technical details ==
*{{tl|PlayStation key press}} - for indicating PS-style gamepad key presses, e.g. {{pskeypress|x}}
This template calls {{Tl|Key press/core}}, which holds the code that otherwise would be repeated several times in {{Tl|Key press}}, thus simplifying the code.
*{{tl|kbd}} - for indicating longer input strings like usernames (doesn't simulate the appearance of keys)
*{{tl|samp}} - for example output
*{{tl|code}} - for computer source code generally
*{{tl|var}} - for computer and mathematics variables
*{{tl|varserif}} - same as {{tnull|var}} but differentiates better between "I" (upper-case "i") and "l" (lower-case "L")


<includeonly>
== See also ==
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
* {{Tl|Button}} – produces a similar visual effect, but without the semantic markup, e.g. {{Button|sample text}}<includeonly>
[[Category:Programming typing-aid templates]]
<!-- Categories go here -->
<!--[[Category:Graphic templates]] - Don't add this one; this isn't a graphic template, as it's all done in CSS.-->
[[Category:Semantic markup templates]]
[[Category:Software templates]]


[[be-x-old:Шаблён:Клявіша]]
[[Category:Formatting templates]]</includeonly>
[[de:Vorlage:Taste]]
[[es:Plantilla:Tecla]]
[[eo:Ŝablono:Klavo]]
[[fr:Modèle:Touche]]
[[ko:틀:키눌림]]
[[hsb:Předłoha:Tasta]]
[[hu:Sablon:Billentyű]]
[[it:Template:Tasto]]
[[ja:Template:Keypress]]
[[pl:Szablon:Klawisz]]
[[pt:Predefinição:Tecla]]
[[ru:Шаблон:Клавиша]]
[[fi:Malline:Näppäin]]
[[tr:Şablon:Tuş]]
[[vi:Tiêu bản:Keypress]]
</includeonly>

Latest revision as of 20:32, 13 September 2022

Emblem-important-yellow.png NOTICE: This is a documentation subpage for Template:Key press:
It contains usage information, categories and other content that is not part of the original template page.


The {{Key press}} template can be used to visually illustrate keystrokes. Typographically, it works best with examples that are separated from the normal flow of text, e.g. in table cells. It can also be used in lists (as on this page), but it may be a good idea to add an empty line between each list item, so the key borders won't overlap each other.

Example:

{{Key press|A}} produces A

Keystroke combinations

To illustrate keystroke combinations, just use extra parameters:

{{Key press|Alt|P}} produces Alt+P
{{Key press|Ctrl|Alt|Del}} produces Ctrl+Alt+Del

This template currently handles up to five (5) key name parameters; which should be more than enough to accomodate any possible simultaneous keystrokes.

When you feed several key names to this template, it adds a + with no surrounding whitespace. This means it can't line wrap, but when you show key combinations, for instance in a table, then that might cause overflow issues due to content being too wide for its container. The workaround in such instances is to manually build the key combination with spaces around the + so it can line wrap, like this:

{{Key press|Ctrl}} + {{Key press|Alt}} + {{Key press|Del}} produces Ctrl + Alt + Del

On the other hand, to illustrate Windows Alt codes, you might want to use separate templates with no intervening punctuation or whitespace. In most Windows systems in North America and Western Europe, for example, the plus–minus sign (±) can be entered by holding down the Alt key while entering 0177 (with the numeric keypad). This could be illustrated as follows:

{{Key press|Alt|0}}{{Key press|1}}{{Key press|7}}{{Key press|7}} produces Alt+0177

Wikilinks

If there is an article about the key, you can wikilink the key's name just like any other wikitext, just like so:

{{Key press|[[wikipedia:Alt key|Alt]]}} produces Alt

When you are wikilinking the keys, please ensure that you are piping to the correct page (e.g. [[wikipedia:Control key|Ctrl]] instead of [[wikipedia:Ctrl]], which leads to a disambiguation page).

Wiki characters

Some wiki markup characters, like the pipe symbol, the semicolon and the equality sign, need to be entered using the {{!}}, {{;}} and {{=}} templates:

{{Key press|{{!}}}} produces |
{{Key press|{{;}}}} produces ;
{{Key press|{{=}}}} produces =


Alternately, {{Key press|<nowiki>|</nowiki>}} is also an option.

Key symbols

Some key names have a fitting unicode character, and in those instances this template automatically adds such symbols to the following keys:

{{Key press|Caps Lock}} produces  Caps Lock
{{Key press|Shift}} produces  Shift
{{Key press|Enter}} produces  Enter
{{Key press|Tab}} produces Tab 
{{Key press|Backspace}} produces ← Backspace
{{Key press|Cmd}} produces  Cmd
{{Key press|Opt}} produces  Opt
{{Key press|Up}} produces
{{Key press|Down}} produces
{{Key press|Left}} produces
{{Key press|Right}} produces


There are no characters for the Windows key and Menu key, so this template shows approximate characters for them in the following way:

{{Key press|Win}} produces  Win
{{Key press|Menu}} produces  Menu

Video games

Video game controllers often have specialized input labels that do not map quite as easily. The following are mappings for various game consoles and input features.

Directional input

The following should only be used when the input sequence uses something other than the primary input, or mixes input between directional devices.

{{Key press|l-down}} produces L↓
{{Key press|c-left}} produces C←
{{Key press|r-up}} produces R↑

Stick specific diagonals are also supported:

{{Key press|l-nw}} produces L ↖
{{Key press|c-se}} produces C ↘
{{Key press|r-ne}} produces R ↗

Technical details

This template calls {{Key press/core}}, which holds the code that otherwise would be repeated several times in {{Key press}}, thus simplifying the code.

See also

  • {{Button}} – produces a similar visual effect, but without the semantic markup, e.g. sample text