From 1e70d95724e7883702d14255cf7614854cae051b Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Thu, 13 Apr 2017 10:23:04 +1200 Subject: [PATCH] Don't unwrap for unknown keys --- ports/glutin/window.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index 7fd69d51a9e..87f583f65b3 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -373,11 +373,16 @@ impl Window { } else { // Only send the character if we can print it (by ignoring characters like backspace) if !ch.is_control() { - let event = WindowEvent::KeyEvent(Some(ch), - Window::char_to_script_key(ch).unwrap(), - KeyState::Pressed, - modifiers); - self.event_queue.borrow_mut().push(event); + match Window::char_to_script_key(ch) { + Some(key) => { + let event = WindowEvent::KeyEvent(Some(ch), + key, + KeyState::Pressed, + modifiers); + self.event_queue.borrow_mut().push(event); + } + None => {} + } } } self.last_pressed_key.set(None);