gpu-tracing
gpu-tracing copied to clipboard
Close window with escape key
Event::WindowEvent {
event: WindowEvent::KeyboardInput { input, .. },
window_id,
} if window_id == window.id() => {
if input.virtual_keycode == Some(VirtualKeyCode::Escape) {
*control_flow = ControlFlow::Exit
}
}
In newer versions of winit (0.29) this is done slightly differently:
event_loop.run(|event, control_target| {
control_target.set_control_flow(ControlFlow::Poll);
match event {
Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => control_target.exit(),
...
}
...
I.e., you can replace *control_flow = ControlFlow::Exit with control_target.exit().