Template:Key press/doc: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
(Finishing this doc. Adding explanation that it takes up to 5 key parameters, and error logs if it gets more.)
(Adding examples with the arrow keys, so people can copy and paste those symbols.)
Line 15: Line 15:
:<code><nowiki>{{keypress|[[Alt key|Alt]]|P}}</nowiki></code> produces {{keypress|[[Alt key|Alt]]|P}}
:<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}}
:<code><nowiki>{{keypress|[[Ctrl]]|Alt|Del}}</nowiki></code> produces {{keypress|[[Ctrl]]|Alt|Del}}
=== Key symbols ===


Some key names have a fitting unicode character. This template automatically adds such "icons" to the following key names:
Some key names have a fitting unicode character. This template automatically adds such "icons" to the following key names:
Line 23: Line 25:
:<code><nowiki>{{keypress|Tab}}</nowiki></code> produces {{keypress|Tab}}
:<code><nowiki>{{keypress|Tab}}</nowiki></code> produces {{keypress|Tab}}
:<code><nowiki>{{keypress|Backspace}}</nowiki></code> produces {{keypress|Backspace}}
:<code><nowiki>{{keypress|Backspace}}</nowiki></code> produces {{keypress|Backspace}}
This template has no special handling for the arrow key symbols. But here is how we usually code the arrow keys, so you can copy and paste the code for them:
:<code><nowiki>{{keypress|←}}</nowiki></code> produces {{keypress|←}}
:<code><nowiki>{{keypress|↑}}</nowiki></code> produces {{keypress|↑}}
:<code><nowiki>{{keypress|↓}}</nowiki></code> produces {{keypress|↓}}
:<code><nowiki>{{keypress|→}}</nowiki></code> produces {{keypress|→}}


=== Technical details ===
=== Technical details ===

Revision as of 18:56, 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 keystroke combinations, just use extra parameters:

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

Key symbols

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

This template has no special handling for the arrow key symbols. But here is how we usually code the arrow keys, so you can copy and paste the code for them:

{{keypress|←}} produces
{{keypress|↑}} produces
{{keypress|↓}} produces
{{keypress|→}} produces

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 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.

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

See also

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