Class SlowKeys

Class Documentation

class SlowKeys

Enables configuring slow keys at runtime.

Slow keys is an accessibility feature that enables the rejection of keypresses that don’t last long enough. It can be useful in cases where the user has issues that cause them to press buttons accidentally.

You can optionally assign handlers for when the key is pressed down, is rejected, or when the press is accepted.

Remark

Since MirAL 5.5

Public Functions

explicit SlowKeys(miral::live_config::Store &config_store)

Construct a SlowKeys instance with access to a live config store.

Available options:

  • {slow_keys, enable}: Enable or disable slow keys.

  • {slow_keys, hold_delay}: How much time in milliseconds must pass between keypresses to not be rejected.

void operator()(mir::Server &server)
SlowKeys &enable()
SlowKeys &disable()
SlowKeys &hold_delay(std::chrono::milliseconds hold_delay)

Configures the duration a key has to be pressed down for to register as a key press.

Note

The default hold delay is 200 milliseconds.

SlowKeys &on_key_down(std::function<void(MirKeyboardEvent const*)> &&on_key_down)

Configures the callback that’s invoked when the key is pressed down. Useful for providing feedback to users.

SlowKeys &on_key_rejected(std::function<void(MirKeyboardEvent const*)> &&on_key_rejected)

Configures the callback that’s invoked when a press is rejected. Useful for providing feedback to users.

SlowKeys &on_key_accepted(std::function<void(MirKeyboardEvent const*)> &&on_key_accepted)

Configures the callback that’s invoked when a press is accepted. Useful for providing feedback to users.

Public Static Functions

static auto enabled() -> SlowKeys

Creates a SlowKeys instance that’s enabled by default.

static auto disabled() -> SlowKeys

Creates a SlowKeys instance that’s disabled by default.