Fix key_press event not only on key down

This commit is contained in:
Stephen Seo 2021-12-16 11:19:32 +09:00
parent 7fb3525ec7
commit 7616f1e3f2

View file

@ -3,7 +3,7 @@ mod display;
mod mpd_handler;
use ggez::conf::{WindowMode, WindowSetup};
use ggez::event::winit_event::{KeyboardInput, ModifiersState};
use ggez::event::winit_event::{ElementState, KeyboardInput, ModifiersState};
use ggez::event::{self, ControlFlow, EventHandler};
use ggez::graphics::{self, Rect};
use ggez::{ContextBuilder, GameError};
@ -79,6 +79,7 @@ fn main() -> Result<(), String> {
input:
KeyboardInput {
virtual_keycode: Some(keycode),
state,
..
},
is_synthetic: _,
@ -90,8 +91,10 @@ fn main() -> Result<(), String> {
}
_ => (),
}
if state == ElementState::Pressed {
display.key_down_event(ctx, keycode, modifiers_state.into(), false);
}
}
event::winit_event::WindowEvent::Resized(phys_size) => {
graphics::set_screen_coordinates(
ctx,