Skip to content

Commit

Permalink
fix keyboard input
Browse files Browse the repository at this point in the history
  • Loading branch information
Grokmoo committed Dec 24, 2024
1 parent d8041d5 commit a054387
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/winit_io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ impl WinitIo {
context.set_mouse_pos((position.x as f32 / self.scale_factor, position.y as f32 / self.scale_factor).into());
},
KeyboardInput { event, .. } => {
if let Some(str) = event.text.as_ref() {
if let ElementState::Pressed = event.state {
for c in str.chars() {
context.push_character(c);
}
}
}

match &event.logical_key {
Key::Named(named_key) => {
if let ElementState::Released = event.state {
Expand All @@ -125,12 +133,7 @@ impl WinitIo {
}
}
},
Key::Character(c) => {
for c in c.chars() {
context.push_character(c);
}
},
Key::Unidentified(_) | Key::Dead(_) => (),
Key::Character(_) | Key::Unidentified(_) | Key::Dead(_) => (),
}
},
_ => (),
Expand Down

0 comments on commit a054387

Please sign in to comment.