Template:Key press/doc: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
No edit summary
(Updating this /doc since I have just reworked the template. Intermediate save, more coming soon.)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE. -->
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE. -->
==Usage==
 
A template for illustrating keystrokes.
This is the {{tl|keypress}} template.
 
It can be used to illustrate keystrokes.


Example:
Example:
* <code><nowiki>{{keypress|[[Alt key|Alt]]}}</nowiki></code> produces {{keypress|[[Alt key|Alt]]}}
:<code><nowiki>{{keypress|A}}</nowiki></code> produces {{keypress|A}}
 
If there is an article about the key you can wikilink the key's name like any other wiki text. Like this:
:<code><nowiki>{{keypress|[[Alt key|Alt]]}}</nowiki></code> produces {{keypress|[[Alt key|Alt]]}}
 
To illustrate multiple keystrokes, just use extra parameters (max 4):
:<code><nowiki>{{keypress|[[Alt key|Alt]]|P}}</nowiki></code> produces {{keypress|[[Alt key|Alt]]|P}}
:<code><nowiki>{{keypress|[[Ctrl]]|Alt|Del}}</nowiki></code> produces {{keypress|[[Ctrl]]|Alt|Del}}
 
Some key names have a fitting unicode character. This template automatically adds such "icons" to the following key names:
:<code><nowiki>{{keypress|Shift}}</nowiki></code> produces {{keypress|Shift}}
:<code><nowiki>{{keypress|Enter}}</nowiki></code> produces {{keypress|Enter}}
:<code><nowiki>{{keypress|Cmd}}</nowiki></code> produces {{keypress|Cmd}}
:<code><nowiki>{{keypress|Opt}}</nowiki></code> produces {{keypress|Opt}}
:<code><nowiki>{{keypress|Tab}}</nowiki></code> produces {{keypress|Tab}}
:<code><nowiki>{{keypress|Backspace}}</nowiki></code> produces {{keypress|Backspace}}
 
=== Technical details ===
 
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>{{keypress|Ctrl}} + {{keypress|Alt}} + {{keypress|Del}}</nowiki></code> produces {{keypress|Ctrl}} + {{keypress|Alt}} + {{keypress|Del}}


To illustrate multiple keystrokes, just use extra parameters (max 10):
This template calls {{tl|keypress/core}}, which holds the code that otherwise would be repeated several times in {{tl|keypress}}, thus simplifying the code in {{tl|keypress}}.
* <code><nowiki>{{keypress|[[Alt key|Alt]]|P}}</nowiki></code> produces {{keypress|[[Alt key|Alt]]|P}}
* <code><nowiki>{{keypress|[[Ctrl]]|Alt|Del}}</nowiki></code> produces {{keypress|[[Ctrl]]|Alt|Del}}


If the icon has an accompanying unicode character, it will be added automatically:
=== See also ===
* <code><nowiki>{{keypress|Shift}}</nowiki></code> produces {{keypress|⇧ Shift}}
* <code><nowiki>{{keypress|Enter}}</nowiki></code> produces {{keypress|↵ Enter}}
* <code><nowiki>{{keypress|Cmd}}</nowiki></code> produces {{keypress|⌘ Cmd}}
* <code><nowiki>{{keypress|Opt}}</nowiki></code> produces {{keypress|⌥ Opt}}
* <code><nowiki>{{keypress|Tab}}</nowiki></code> produces {{keypress|Tab ⇆}}


==See also==
* {{tl|pskeypress}} – For PlayStation-style controllers.
* {{tl|Keypress/Switch}} &ndash; automatically adds the unicode characters when possible.
* {{tl|pskeypress}}


<includeonly><!--
<includeonly>
++++ PLEASE ADD CATEGORIES AND INTERWIKIS BELOW THIS LINE, THANK YOU. -->
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS -->
[[Category:Computing templates|{{PAGENAME}}]]
[[Category:Computing templates|{{PAGENAME}}]]
[[Category:Graphic templates|{{PAGENAME}}]]
[[Category:Graphic templates|{{PAGENAME}}]]

Revision as of 16:59, 23 March 2009


This is the {{keypress}} template.

It can be used to illustrate keystrokes.

Example:

{{keypress|A}} produces A

If there is an article about the key you can wikilink the key's name like any other wiki text. Like this:

{{keypress|[[Alt key|Alt]]}} produces Alt

To illustrate multiple keystrokes, just use extra parameters (max 4):

{{keypress|[[Alt key|Alt]]|P}} produces Alt+P
{{keypress|[[Ctrl]]|Alt|Del}} produces Ctrl+Alt+Del

Some key names have a fitting unicode character. This template automatically adds such "icons" to the following key names:

{{keypress|Shift}} produces  Shift
{{keypress|Enter}} produces  Enter
{{keypress|Cmd}} produces  Cmd
{{keypress|Opt}} produces  Opt
{{keypress|Tab}} produces Tab 
{{keypress|Backspace}} produces ← Backspace

Technical details

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:

{{keypress|Ctrl}} + {{keypress|Alt}} + {{keypress|Del}} produces Ctrl + Alt + Del

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

See also

  • {{pskeypress}} – For PlayStation-style controllers.