feat: Add Key.Space to Key namespace. (#4311)

This commit is contained in:
Daniel 2024-01-10 16:25:31 +01:00 committed by GitHub
parent 9b7a9b3f77
commit 807a233849
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View file

@ -41,6 +41,7 @@ against the constants below.
- **`ControlR`**
- **`Meta`**
- **`MetaR`**
- **`Space`**
- **`UpArrow`**
- **`DownArrow`**
- **`LeftArrow`**

View file

@ -287,9 +287,6 @@ impl EventLoopState {
match key_code {
$($(winit::keyboard::Key::Named(winit::keyboard::NamedKey::$winit) $(if event.location == winit::keyboard::KeyLocation::$pos)? => $char.into(),)*)*
winit::keyboard::Key::Character(str) => str.as_str().into(),
// Space is handled separately: When pressed, event.text would be Some(" ") and all is well. But when released,
// event.text is always empty, so we'd never produce a release event.
winit::keyboard::Key::Named(winit::keyboard::NamedKey::Space) => " ".into(),
_ => {
if let Some(text) = &event.text {
text.as_str().into()

View file

@ -47,6 +47,8 @@ macro_rules! for_each_special_keys {
'\u{0017}' # Meta # Qt_Key_Key_Meta # Super(Left) # Meta_L ;
'\u{0018}' # MetaR # # Super(Right) # Meta_R ;
'\u{0020}' # Space # Qt_Key_Key_Space # Space # space ;
'\u{F700}' # UpArrow # Qt_Key_Key_Up # ArrowUp # Up ;
'\u{F701}' # DownArrow # Qt_Key_Key_Down # ArrowDown # Down ;
'\u{F702}' # LeftArrow # Qt_Key_Key_Left # ArrowLeft # Left ;