slint::Keys Class
class Keys;#include <slint.h>A Keys is created by the @keys(…) macro in Slint and defines which key event(s) activate a KeyBinding.
Public Functions
Section titled “Public Functions”slint::Keys::Keys()=default
Returns an empty keys instance, which never matches any key event.
slint::Keys::Keys(const Keys &)=default
Copy constructor.
slint::Keys::Keys(Keys &&)=default
Move constructor.
operator=
Section titled “ operator=”slint::Keys & slint::Keys::operator=(const Keys &)=default
Copy assignment operator.
operator=
Section titled “ operator=”slint::Keys & slint::Keys::operator=(Keys &&)=default
Move assignment operator.
to_parts
Section titled “ to_parts”SharedVector<SharedString> slint::Keys::to_parts() const
Decompose this Keys value into a list of string parts that from_parts accepts.
A Keys value that is converted into parts and then re-created from those parts with from_parts will be equal to the input Keys value. Note that while the round-trip guarantees the resulting Keys are equal, the parts returned here can be different from the parts used to construct the Keys.
A part is not necessarily printable, so a text format storing parts has to quote or escape them.
An empty Keys returns an empty vector.
to_string
Section titled “ to_string”SharedString slint::Keys::to_string() const
Returns a string that looks native on the current platform.
For example, the shortcut created with @keys(Meta + Control + A) will be converted like this:
- macOS:
⌃⌘A - Windows:
Win+Ctrl+A - Linux:
Super+Ctrl+A
Note that this functions output is best-effort and may be adjusted/improved at any time, do not rely on this output to be stable!
Public Static Functions
Section titled “Public Static Functions” from_parts
Section titled “ from_parts”static std::optional<Keys> slint::Keys::from_parts(R &&parts)
Create a Keys from a range of string parts, e.g. {"Control", "Shift?", "Z"}.
Each element is either a modifier (Control, Shift, Alt, Meta, Shift?, Alt?) or a key name from the Key namespace (case-sensitive). If not found, it is treated as a string literal (must be a single lowercase grapheme cluster).
Parts are taken verbatim — they are not trimmed — so whitespace is significant: " ", "\t" and "\n" are literal spellings of the Space, Tab and Return keys. A part must match a modifier or key exactly; " Control " is not the Control modifier. Empty parts are skipped.
Returns std::nullopt on parse failure.
parts may be any range whose elements are convertible to std::string_view, such as a std::vector<std::string>.
Friends
Section titled “Friends” operator==
Section titled “ operator==”bool operator==(const Keys &a, const Keys &b)
Equality operator, returns true if the two Keys instances are equal, i.e. they match the same key events.
operator!=
Section titled “ operator!=”bool operator!=(const Keys &a, const Keys &b)
Inequality operator, returns true if the two Keys instances are not equal, i.e. they match different key events.
© 2026 SixtyFPS GmbH