diff options
| -rw-r--r-- | graphics/src/lib.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs index 9917a94..81ac16e 100644 --- a/graphics/src/lib.rs +++ b/graphics/src/lib.rs @@ -109,7 +109,12 @@ impl Window { /// Get the last key pressed pub fn get_key_pressed(&self) -> Option<KeyCode> { - self.handle.borrow_mut().get_key_pressed() + // We dont want to require a mutable reference + // to read the last key pressed + self.handle + .try_borrow_mut() + .ok() + .and_then(|mut h| h.get_key_pressed()) } /// Get audio data for the window |