User:Taz/Template:Kbdchartkey
This template derived from the StrategyWiki template Template:Kbdchartkey (documentation), which is released under the CC BY-SA 3.0 license (view authors, documentation authors). |
Usage
This template draws a box representing one key in a keyboard layout and provides parameters for size, background color, up to 6 prepositioned labels, and foreground/background colors for 3 of those labels.
This is a sub-template of User:Taz/Template:Kbdchart.
Syntax
{{kbdchartkey |<posflw=value> |<poslft=px> |<postop=px> |<poswid=px> |<poshgh=px> |<colbkg=color> |<keycap=Capital Key Label> |<keylow=Lowercase Key Label> |<keytxt=Game Label> |<keyshf=Game Shift Label> |<bkgshf=color> |<colshf=color> |<keyctl=Game Ctrl Label> |<bkgctl=color> |<colctl=color> |<keyalt=Game Alt Label> |<bkgalt=color> |<colalt=color> }}
Parameters
Position parameters | ||||||
---|---|---|---|---|---|---|
Parameter | default | Explanation | ||||
posflw | absolute | The position property. valid values: static, relative, fixed, absolute, sticky. | ||||
poslft | 0 | Position offset in pixels from the left. Use 10, not 10px. | ||||
postop | 0 | Position offset in pixels from the top. Use 10, not 10px. | ||||
poswid | 72 | Width in pixels. Use 10, not 10px. | ||||
poshgh | 72 | Height in pixels. Use 10, not 10px. | ||||
Label parameters | ||||||
keycap | Cap key | Upper-left corner label, bold text. Can signify the capitalized symbol on the key. | ||||
keylow | (unset) | Lower-left corner label, bold text. Can signify the lowercase symbol on the key. | ||||
keytxt | Caption | One row above lower-left corner label, normal text. Drops to lower-left corner if keylow not present. Can signify the game function of the key. | ||||
keyshf | Shift | Upper-right corner label, normal text. Can signify the game function of the Shift+key combination. Pass keyshf= to leave this row present when empty. | ||||
keyctl | Ctrl | 2nd row upper-right corner label, normal text. Rises if keyshf is not present. Can signify the game function of the Ctrl+key combination. Pass keyctl= to leave this row present when empty. | ||||
keyalt | Alt | 3rd row upper-right corner label, normal text. Rises if keyshf and/or keyctl are missing. | ||||
Color parameters | ||||||
colbkg | non | Background color for the overall box. Valid color presets:
| ||||
bkgshf | transparent | Background color of the keyshf label. | ||||
colshf | #00a | Text color of the keyshf label. | ||||
bkgctl | transparent | Background color of the keyctl label. | ||||
colctl | #0a0 | Text color of the keyctl label. | ||||
bkgalt | transparent | Background color of the keyalt label. | ||||
colalt | #a00 | Text color of the keyalt label. |
Examples
A standard key with default labels. (Use posflw=relative to position inline and specify keylow to show default.)
{{User:Taz/Template:Kbdchartkey|posflw=relative|keylow=Low key}}
A layout diagram using this template might use the following widths to show various key sizes in a layout: for 1.25x use poswid=90; for 1.5x use poswid=108; for 1.75x use poswid=126; for 2.25x use poswid=162; for 2.75x use poswid=198. These sizes seem to work well together in a layout such as User:Taz/Template:Kbdchart, but another layout might prefer different sizes.
To create a layout diagram of several keys, create a div with relative position. Individual keys use the default posflw to anchor them in the div, and use poslft and postop to position within the div. Keys with the same postop will appear to be the same row, while keys with the same poslft will appear column-aligned.
<div style="position:relative;height:150px;overflow:auto;"> <!-- row 1 --> {{User:Taz/Template:Kbdchartkey| poslft=0| postop=0| keytxt=1.0x key}} {{User:Taz/Template:Kbdchartkey| poslft=72| postop=0| poswid=90| keytxt=1.25x key}} {{User:Taz/Template:Kbdchartkey| poslft=162| postop=0| poswid=108| keytxt=1.5x key}} <!-- row 2 --> {{User:Taz/Template:Kbdchartkey| poslft=0| postop=72| poswid=126| keytxt=1.75x key}} {{User:Taz/Template:Kbdchartkey| poslft=126| postop=72| poswid=162| keytxt=2.25x key}} </div>