Listen for Q to exit
Getty Ritter
7 years ago
61 | 61 | } |
62 | 62 | |
63 | 63 | window.run(|event| { |
64 |
use glutin::{ControlFlow, Event, WindowEvent |
|
64 | use glutin::{ControlFlow, Event, WindowEvent, VirtualKeyCode}; | |
65 | 65 | |
66 | if let Event::WindowEvent { event, .. } = event { | |
67 | if let WindowEvent::Closed = event { | |
68 |
|
|
66 | match event { | |
67 | Event::WindowEvent { event: WindowEvent::Closed, .. } => | |
68 | return ControlFlow::Break, | |
69 | Event::WindowEvent { event: WindowEvent::KeyboardInput { input: k, .. }, .. } => { | |
70 | match k.virtual_keycode { | |
71 | Some(VirtualKeyCode::Q) => | |
72 | return ControlFlow::Break, | |
73 | _ => println!("{:#?}", k), | |
74 | } | |
69 | 75 | } |
76 | _ => (), | |
70 | 77 | } |
71 | 78 | |
72 | 79 | unsafe { |