From 41088387134cca07ddc93842bbbc953a1f7e263a Mon Sep 17 00:00:00 2001 From: bbb651 Date: Sun, 15 Jun 2025 22:17:28 +0300 Subject: [PATCH] Add `repeat` field to `keyboard::Event::KeyPressed` --- core/src/keyboard/event.rs | 3 +++ test/src/simulator.rs | 1 + winit/src/conversion.rs | 2 ++ 3 files changed, 6 insertions(+) diff --git a/core/src/keyboard/event.rs b/core/src/keyboard/event.rs index 88c57b21..0c483650 100644 --- a/core/src/keyboard/event.rs +++ b/core/src/keyboard/event.rs @@ -29,6 +29,9 @@ pub enum Event { /// The text produced by the key press, if any. text: Option, + + /// Whether the event was the result of key repeat. + repeat: bool, }, /// A keyboard key was released. diff --git a/test/src/simulator.rs b/test/src/simulator.rs index 010c521a..4d31345b 100644 --- a/test/src/simulator.rs +++ b/test/src/simulator.rs @@ -381,6 +381,7 @@ pub fn press_key( ), location: keyboard::Location::Standard, modifiers: keyboard::Modifiers::default(), + repeat: false, text, }) } diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 29f5d50b..9d76997c 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -249,6 +249,7 @@ pub fn window_event( location, logical_key, physical_key, + repeat, .. } = event; @@ -279,6 +280,7 @@ pub fn window_event( modifiers, location, text, + repeat, } } winit::event::ElementState::Released => {