Difference between revisions of "Template:Kbd/doc"
m (→Usage) |
m |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | The template {{tlg|kbd}} is for explicitly indicating that the content inside it represents input from a keyboard or other source (speech recognition software, standard input, etc.). | |
− | + | It uses the XHML element for keyboard input {{tag|kbd}} which exists for this purpose, and applies some styling to it, namely a faint grey background (borrowed from the related template {{tlg|code=yes|nowrap=yes|key press}}) and slight CSS letter‐spacing to suggest individually entered characters. It retains the default monospaced (non‐proportional) font style of the {{tag|kbd|open}} element. Because it uses {{tag|kbd}} instead of simply applying visual style effects, it is semantic markup that conveys meaning, and it can be further acted upon by the user agent (e.g. with custom local style sheets). This tag is the exact opposite of {{tlg|code=yes|samp}}, which is for example output. | |
== Usage == | == Usage == | ||
− | The template takes one mandatory parameter, the content to be marked up. | + | The template takes one mandatory parameter, the content to be marked up. If this content contains an equals sign “=”, the parameter '''must''' be explicitly named {{para|1}}, or the template will fail. (This is a limitation of the MediaWiki software, not the template.) It is always safer to use {{para|1}} syntax. It may be used as a container for {{tlg|code=yes|var}} or {{tag|var}} when the example keyboard input contains or consists entirely of a variable. It may also be used with (but not inside) {{tlg|code=yes|code}} or with {{tag|code}} (it generally should not be used inside the latter, as input is not a part of source code, but something that interacts with it; however, this style can be used to illustrate computer display of mixed type, as illustrated below). |
There is an optional parameter {{para|spacing=no}} (or {{para|spacing=n}} or any other value), to get rid of the slight letter spacing, which can look awkward on long passages of input. | There is an optional parameter {{para|spacing=no}} (or {{para|spacing=n}} or any other value), to get rid of the slight letter spacing, which can look awkward on long passages of input. | ||
Line 11: | Line 11: | ||
== Examples == | == Examples == | ||
− | * {{ | + | * {{tlg|code=yes|nolink=yes|kbd|71077345}}: “Entering {{kbd|71077345}} on a calculator and turning it upside down appears to spell ''ShellOil''.” |
− | * {{ | + | * {{tlg|code=yes|nolink=yes|kbd|1{{=}}ssh <nowiki>{{var|hostname}}</nowiki>}} with {{tlg|code=yes|nolink=yes|samp|%}}: “At the {{samp|%}} prompt, the user must enter {{kbd|1=ssh {{var|hostname}}}}.” |
− | * {{ | + | * {{tlg|code=yes|nolink=yes|kbd|1{{=}}ssh <nowiki>{{var|hostname}}</nowiki>}} with {{tlg|code=yes|nolink=yes|samp|%}} and {{tlg|code=yes|nolink=yes|key press|Enter}}: “At the {{samp|%}} prompt, the user must input {{kbd|1=ssh {{var|hostname}}}}{{key press|Enter}}.” |
− | * Inside {{tag|code}}: | + | * Inside {{tag|code}}: “The commandline should read: <code>% {{kbd|1=ssh {{var|hostname}}}}</code> (where {{var|hostname}} is the IP address or domain name of the system to connect to); if this is correct, press {{key press|Enter}}.” |
− | [[Category: | + | === See also === |
+ | |||
+ | * {{tlg|key press}} – designed to illustrate keys and keystrokes on a computer keyboard. | ||
+ | * {{tlg|summertimesaga button}} – produces a visual effect for ''Summertime Saga'' interface elements. | ||
+ | |||
+ | [[Category:Templates]][[Category:Semantic markup templates]][[Category:Templates documentation]] |
Latest revision as of 16:09, 21 July 2020
The template {{kbd}} is for explicitly indicating that the content inside it represents input from a keyboard or other source (speech recognition software, standard input, etc.).
It uses the XHML element for keyboard input <kbd>…</kbd>
which exists for this purpose, and applies some styling to it, namely a faint grey background (borrowed from the related template {{key press}}
) and slight CSS letter‐spacing to suggest individually entered characters. It retains the default monospaced (non‐proportional) font style of the <kbd>
element. Because it uses <kbd>…</kbd>
instead of simply applying visual style effects, it is semantic markup that conveys meaning, and it can be further acted upon by the user agent (e.g. with custom local style sheets). This tag is the exact opposite of {{samp}}
, which is for example output.
Usage
The template takes one mandatory parameter, the content to be marked up. If this content contains an equals sign “=”, the parameter must be explicitly named |1=
, or the template will fail. (This is a limitation of the MediaWiki software, not the template.) It is always safer to use |1=
syntax. It may be used as a container for {{var}}
or <var>…</var>
when the example keyboard input contains or consists entirely of a variable. It may also be used with (but not inside) {{code}}
or with <code>…</code>
(it generally should not be used inside the latter, as input is not a part of source code, but something that interacts with it; however, this style can be used to illustrate computer display of mixed type, as illustrated below).
There is an optional parameter |
(or |
or any other value), to get rid of the slight letter spacing, which can look awkward on long passages of input.
Examples
{{kbd|71077345}}
: “Entering 71077345 on a calculator and turning it upside down appears to spell ShellOil.”{{kbd|1=ssh {{var|hostname}}}}
with{{samp|%}}
: “At the % prompt, the user must enter ssh hostname.”{{kbd|1=ssh {{var|hostname}}}}
with{{samp|%}}
and{{key press|Enter}}
: “At the % prompt, the user must input ssh hostname↵ Enter.”- Inside
<code>…</code>
: “The commandline should read:% ssh hostname
(where hostname is the IP address or domain name of the system to connect to); if this is correct, press ↵ Enter.”
See also
- {{key press}} – designed to illustrate keys and keystrokes on a computer keyboard.
- {{summertimesaga button}} – produces a visual effect for Summertime Saga interface elements.