Skip to content

Kbd

kbd · Elements

A key, drawn as a key.

Import

cpp
#include "gbui/widgets/kbd.hpp"

Example

Nothing is downloaded until you press it.

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

OptionTypeDefaultWhat it does
sizefloat11.0f
separatorstd::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.
namestd::string_viewAnnounced 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.

Released under the LGPL-3.0-or-later licence.