When holding down a key the system usually injects repeated keypresses.
winit::event::KeyEvent
has a repeat
flag for this, which makes it easy to handle non-text-input interactions that rely on holding down a key correctly.
Note that it is possible to distinguish key repeat events already, but only by manually tracking key press state; currently (at least on linux in wayland) holding down space and releasing it after two repeats generates a sequence of events like this:
- KeyPressed(Space)
- KeyPressed(Space)
- KeyPressed(Space)
- KeyReleased(Space)
I would suggest adding a repeat: bool
field to KeyEvent
, and to consider whether iced::keyboard::on_key_press/release
should exist as variants that include/exclude repeats, or pass along repeat: bool
as an argument to the provided function.
I’m happy to provide a PR contribution for these changes but would like some comments on the preferred way to handle the subscription functions.