Kbd
kbd · Elements
A key, drawn as a key.
Import
cpp
#include "gbui/widgets/kbd.hpp"Example
cpp
NodeId kbd(Ui& ui, std::string_view keys, const KbdOptions& options = {});One or more keycaps. The string is split on separator, so "Ctrl+P" is two caps and "Ctrl" is one. Whitespace around each part is trimmed, because "Ctrl + P" is how people write it.
API
KbdOptions
| Option | Type | Default | What it does |
|---|---|---|---|
size | float | 11.0f | |
separator | std::string_view | "+" | What separates the keys in the string, and what is drawn between the caps. + is the desktop convention and - is Emacs's. Setting it to nothing draws the whole string as one cap, which is what a key with a plus in its name needs. |
name | std::string_view | Announced instead of the keys. A reader hears "Control Shift P" rather than three letters when the caller spells it out; empty reads the caps as they are written. |