diff --git a/glutin_examples/src/lib.rs b/glutin_examples/src/lib.rs index 059df51b48..393d1beb7d 100644 --- a/glutin_examples/src/lib.rs +++ b/glutin_examples/src/lib.rs @@ -4,7 +4,8 @@ use std::num::NonZeroU32; use std::ops::Deref; use raw_window_handle::HasRawWindowHandle; -use winit::event::{Event, WindowEvent}; +use winit::event::{Event, KeyEvent, WindowEvent}; +use winit::keyboard::{Key, NamedKey}; use winit::window::WindowBuilder; use glutin::config::ConfigTemplateBuilder; @@ -28,8 +29,11 @@ pub fn main(event_loop: winit::event_loop::EventLoop<()>) -> Result<(), Box) -> Result<(), Box) -> Result<(), Box window_target.exit(), + WindowEvent::CloseRequested + | WindowEvent::KeyboardInput { + event: KeyEvent { logical_key: Key::Named(NamedKey::Escape), .. }, + .. + } => window_target.exit(), _ => (), }, Event::AboutToWait => {