Template:Kbd
Template loop detected: Template:Doc
This template's documentation was also ported from Wikipedia, originally from Template:Kbd/doc. The original authors of the documentation are shown on the documentation's edit history page.
Wikipedia's text is available under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
Purpose
This template 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 [X]HTML element <kbd>...</kbd>
(keyboard input) 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}}
, {{Varserif}}
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 |spacing=no
(or |spacing=n
or any other value), to get rid of the slight letter spacing, which can look awkward on long passages of input.
Examples:
{{Kbd
: "Entering 71077345 on a calculator and turning it upside down appears to spell ShellOil."|71077345
}}{{Kbd
with|1=ssh
}}{{Var
|hostname
}}{{Samp
: "At the % prompt, the user must enter ssh hostname."|%
}}{{Kbd
with|1=ssh
}}{{Var
|hostname
}}{{Samp
and|%
}}{{Key press
: "At the % prompt, the user must input ssh hostname↵ Enter."|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." {{Kbd
to get rid of the spacing: Lorem ipsum dolor sit amet|1=Lorem ipsum dolor sit amet
|spacing=0
}}
The above documentation is transcluded from Template:Kbd/doc. (Edit | Page history)
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.