Template:Key/doc: Difference between revisions

From DynamicPageList3 Manual
Content added Content deleted
No edit summary
imported>FrozenPlum
m (mark as having variables extension use)
 
(11 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{doc/start}}
<!-- Documentation here -->
When used, this template displays game controls, supporting both keyboard keys and controller buttons.
When used, this template displays game controls, supporting both keyboard keys and controller buttons.
* Images used by this template are hosted at http://commons.gamepedia.com.
* Images used by this template are hosted at Fandom Commons.
* This template's display is styled using the <code>.keysDark</code> and <code>.keysLight</code> classes located in [[MediaWiki:Common.css]].
* This template's display is styled using the <code>.keysDark</code> and <code>.keysLight</code> classes located in [[MediaWiki:Common.css]].


== Usage ==
== Usage ==
* '''Note:''' For a summary of possible console, key, and button values, see [[Template:Key/library]].
* '''Note:''' For a summary of possible console, key, and button values, see [[wikia:Template:Key/library|key library]].


=== Keyboard ===
=== Keyboard ===
If using the template for keyboard keys, there is only one required input. For mouse usage, see the [[#Consoles and controllers]], using "mouse" as the console.
'''<code><nowiki>{{</nowiki>key | keyboard = ''keyboard key'' | keyboardvariant = ''dark or light'' <nowiki>}}</nowiki></code>'''


<code><nowiki>{{key|button}}</nowiki></code>
* The <code>keyboard</code> parameter is the keyboard key to be pressed.
* <code>button</code> is the keyboard key to be pressed. Some key inputs, such as Shift or Tab will automatically add symbols or other formatting. Any other inputs will be output as they are with the first letter capitalized.
* The <code>keyboardvariant</code> parameter is the graphic style and is not required - the template defaults to <code>dark</code>, rendering a white key with black text. Enter <code>dark</code> for dark wikis, or <code>light</code> for light wikis.
* ''Optional'': there is an additional parameter, <code>keyboardvariant</code> which determines whether the key is dark text on a light key (default) or the inverse. This will likely never be used, and if a wiki would prefer light on dark, it should be changed as the default.


=== Controller ===
==== Example ====
<pre>
'''<code><nowiki>{{</nowiki>key | console = ''console type'' | key = ''controller button'' | size = ''optional size'' <nowiki>}}</nowiki></code>'''
Press {{Key|Shift}} and {{Key|F}} at the same time.

* The <code>console</code> parameter is used to state which console the key belongs to. The parameter is '''not''' case-sensitive. See [[Template:Key/library]] for possible values.
* The <code>button</code> parameter is the button to be pressed, such as "A" or "Cross". Note that this template uses the registered trademark names, i.e. "cross" instead of "X" for Playstation buttons, but the template has alternative spellings and entries included. See [[Template:Key/library]] for possible values.
* The <code>size</code> parameter is optional, and sizes the button image. If this parameter is not entered, the default image size is 50px.

== Examples ==
=== Keyboard ===
The <code>keyboardvariant</code> parameter does not usually need to be entered explicitly. A default is generally set during a wiki's spinup. The parameter is used here to illustrate the two available versions.

{{key
| keyboard = caps lock
| keyboardvariant = dark
}}
<pre style="width: 450px;">
{{key
| keyboard = caps lock
| keyboardvariant = dark
}}
</pre>
</pre>
produces:
Press {{Key|Shift}} and {{Key|F}} at the same time.


=== Consoles and controllers ===
Or for light wikis:
<code><nowiki>{{key|console|button|size=optional size}}</nowiki></code>


* <code>console</code> is the console the key belongs to. The parameter is '''not''' case-sensitive and supports many possible consoles. See [[wikia:Template:Key/library|key library]]. for possible values.
{{key
* <code>button</code> is the button to be pressed, such as "A" or "Right Trigger". While the template tries to be intuitive such that the correct input for a button is whatever you think it is, if your attempt at a button isn't working, see [[wikia:Template:Key/library|key library]]. for possible values.
| keyboard = caps lock
* The <code>size</code> parameter is optional, and sizes the button image. If this parameter is not entered, the default image size is 20px.
| keyboardvariant = light
}}
<pre style="width: 450px;">
{{key
| keyboard = caps lock
| keyboardvariant = light
}}
</pre>

Keyboard keys can be entered in shorthand like this:
{{key|caps lock}}
<pre style="width: 450px;">
{{key|caps lock}}
</pre>


=== Controller ===
==== Example ====
<hr>
<pre>
Press {{Key|Xbox|RT}} to open your inventory wheel and select the item with {{Key|Xbox|A}}
{{key
| console = 360
| key = A
| size = 50px
}}
<pre style="width: 450px;">
{{key
| console = 360
| key = A
| size = 50px
}}
</pre>
</pre>


== Change the default colour ==
== Changing the default color ==
The default colour for the keyboard and mouse is suitable for dark-skinned wikis. To change the default settings so it fits for a light-skinned wiki, without having to use ''keyboardvariant = light'' each time you can search for and change these sections in the template:
The default color for the keyboard and mouse is suitable for dark-skinned wikis. To change the default settings so it fits for a light-skinned wiki, without having to use <code>keyboardvariant = light</code> each time, you can search for and change these sections in the template:


Search for: <code>|#default = _White_Mouse_</code><br/>
Search for: <code>|#default = _White_Mouse_</code><br/>
Line 76: Line 41:




Search for: <code><nowiki><kbd class="{{#switch: {{lc:{{{keyboardvariant}}}}} |dark=keysDark|light=keysLight|</nowiki><div style="color: #00ff00;">keysDark}}</div>"></code><br/>
Search for: <code><nowiki><kbd class="{{#switch: {{lc:{{{keyboardvariant}}}}} |dark=keysDark|light=keysLight|</nowiki><div style="color: #00ff00;">keysDark</div>}}"></code><br/>
...and change ''keysDark'' at the end of the line to <code>''keysLight''</code>.
...and change ''keysDark'' at the end of the line to <code>''keysLight''</code>.


{{clear}}
<includeonly>
<includeonly>
<!-- Template categories/interwikis here -->
[[Category:Templates]]
[[Category:Formatting templates]]
[[Category:Templates to simplify or eliminate]]
[[Category:Uses Variables extension]]
</includeonly>
</includeonly>
{{doc/end}}

Latest revision as of 03:44, 30 March 2022

This is the documentation page, it should be transcluded into the main template page. See Template:Documentation for more information

When used, this template displays game controls, supporting both keyboard keys and controller buttons.

  • Images used by this template are hosted at Fandom Commons.
  • This template's display is styled using the .keysDark and .keysLight classes located in MediaWiki:Common.css.

Usage

  • Note: For a summary of possible console, key, and button values, see key library.

Keyboard

If using the template for keyboard keys, there is only one required input. For mouse usage, see the #Consoles and controllers, using "mouse" as the console.

{{key|button}}

  • button is the keyboard key to be pressed. Some key inputs, such as Shift or Tab will automatically add symbols or other formatting. Any other inputs will be output as they are with the first letter capitalized.
  • Optional: there is an additional parameter, keyboardvariant which determines whether the key is dark text on a light key (default) or the inverse. This will likely never be used, and if a wiki would prefer light on dark, it should be changed as the default.

Example

Press {{Key|Shift}} and {{Key|F}} at the same time.

produces: Press {{#vardefine:console|}}{{#vardefine:key|{{{2}}}}}{{#vardefine:keyboard|shift}}Template:!((File:undefined {{#var:key}}.png|alt={{#var:key}}|20px|link=|{{#var:key}}Template:))!{{#var:keyboard}} and {{#vardefine:console|}}{{#vardefine:key|{{{2}}}}}{{#vardefine:keyboard|f}}Template:!((File:undefined {{#var:key}}.png|alt={{#var:key}}|20px|link=|{{#var:key}}Template:))!{{#var:keyboard}} at the same time.

Consoles and controllers

{{key|console|button|size=optional size}}

  • console is the console the key belongs to. The parameter is not case-sensitive and supports many possible consoles. See key library. for possible values.
  • button is the button to be pressed, such as "A" or "Right Trigger". While the template tries to be intuitive such that the correct input for a button is whatever you think it is, if your attempt at a button isn't working, see key library. for possible values.
  • The size parameter is optional, and sizes the button image. If this parameter is not entered, the default image size is 20px.

Example

Press {{Key|Xbox|RT}} to open your inventory wheel and select the item with {{Key|Xbox|A}}

Changing the default color

The default color for the keyboard and mouse is suitable for dark-skinned wikis. To change the default settings so it fits for a light-skinned wiki, without having to use keyboardvariant = light each time, you can search for and change these sections in the template:

Search for: |#default = _White_Mouse_
...and change it to: |#default = _Black_Mouse_


Search for: <kbd class="{{#switch: {{lc:{{{keyboardvariant}}}}} |dark=keysDark|light=keysLight|

keysDark

}}">

...and change keysDark at the end of the line to keysLight.