Changes

Jump to navigation Jump to search
an exit code of an application is <samp> not <kbd> content
{{Documentation subpage}}
<!-- Categories at the bottom of this page, please; interwikis at Wikidata -->

== 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 &#91;[[XHTML|X]]&#93;[[HTML]] element {{tag|kbd}} (''keyboard input'') which exists for this purpose, and applies some styling to it, namely a faint grey background (borrowed from the related template {{tlx|key press}}) and slight [[Cascading style sheets|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 {{tlx|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 {{em|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 {{tlx|var}}, {{tlx|varserif}} or {{tag|var}} when the example keyboard input contains or consists entirely of a variable. It may also be used with (but not inside) {{tlx|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.

Examples:
* {{tnull|kbd|71077345}}: "Entering {{kbd|71077345}} on a calculator and turning it upside down appears to spell ''[[Royal Dutch Shell|ShellOil]]''."
* {{tnull|kbd|1{{=}}ssh <nowiki>{{var|hostname}}</nowiki>}} with {{tnull|samp|%}}: "At the {{samp|%}} prompt, the user must enter {{kbd|1=ssh {{var|hostname}}}}."
* {{tnull|kbd|1{{=}}ssh <nowiki>{{var|hostname}}</nowiki>}} with {{tnull|samp|%}} and {{tnull|key press|Enter}}: "At the {{samp|%}} prompt, the user must input {{kbd|1=ssh {{var|hostname}}}}{{key press|Enter}}."
* 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}}."
* {{tnull|kbd|1{{=}}<nowiki>{{lorem}}</nowiki>|spacing{{=}}0}} to get rid of the spacing: {{kbd|1={{lorem}}|spacing=0}}

<!--The section below only makes sense if you remember that when /doc pages are included into the template page they belong to, their background is light green!
-->Some of these examples may look slightly different outside this documentation, because the default background color varies by page type (articles are stark white, template documentation pale green, most other pages very pale grey). In-article example:

<div style="background:#FFFFFF;">
* {{tnull|kbd|71077345}}: "Entering {{kbd|71077345}} on a calculator and turning it upside down appears to spell ''[[Royal Dutch Shell|ShellOil]]''."
* {{tnull|kbd|1{{=}}ssh <nowiki>{{var|hostname}}</nowiki>}} with {{tnull|samp|%}}: "At the {{samp|%}} prompt, the user must enter {{kbd|1=ssh {{var|hostname}}}}."
* {{tnull|kbd|1{{=}}ssh <nowiki>{{var|hostname}}</nowiki>}} with {{tnull|samp|%}} and {{tnull|key press|Enter}}: "At the {{samp|%}} prompt, the user must input {{kbd|1=ssh {{var|hostname}}}}{{key press|Enter}}."
* 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}}."
* {{tnull|kbd|1{{=}}<nowiki>{{lorem}}</nowiki>|spacing{{=}}0}} to get rid of the spacing: {{kbd|1={{lorem}}|spacing=0}}
</div><!--

The section above only makes sense if you remember that when /doc pages are included into the template page they belong to, their background is light green!
-->


{{Semantic markup templates}}

<includeonly>
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Programming typing-aid templates]]
[[Category:Semantic markup templates]]
[[Category:Wikipedia XHTML tag-replacing templates]]
</includeonly>
Anonymous user

Navigation menu