UI Toolbox logoUI Toolbox
Support

Kbd

A Kbd shows a keyboard shortcut as key caps. Use it in a help text, a tooltip, a menu or a tutorial. It only shows the keys; it does not listen for them.

A pause menu with a search box that shows Ctrl + K, and commands such as Resume, Quick save and Save to a new slot, each with its shortcut as key capsA pause menu with a search box that shows Ctrl + K, and commands such as Resume, Quick save and Save to a new slot, each with its shortcut as key caps

<ui:Label text="Find a command" />
<tb:Kbd keys="Ctrl+K" />
row.Add(new Kbd("Ctrl+Shift+S"));
Member Description
Keys (keys) The keys with "+" between them, such as "Ctrl+Shift+S" or "F5". Each key shows as one cap. Spaces around a key are removed.
Separator (separator) The text between two caps (default "+"). Use "then" for a sequence of keys. An empty text shows no separator.

Tips:

In the examples

Styling

Class Element
tb-kbd The row of caps.
tb-kbd__key One key cap: a border that is 2 px at the bottom, a radius of 4 px, --tb-color-surface-alt and bold small text. It shares these rules with the value of a KeyBindingField.
tb-kbd__separator The text between two caps, in --tb-color-text-muted.
.tb-kbd__key {
    background-color: var(--tb-color-accent);
    color: var(--tb-color-accent-text);
    border-color: var(--tb-color-accent);
}

The KbdDemo scene shows a pause menu that lights the row of the shortcut that you press, the controls screen of a game with the keys of a layout, tutorial hints, the move list of a fighting game and the looks of the key caps.