From 0c2e4cee7c03db5c5c0f0067710c47ede5c5a195 Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Tue, 15 Dec 2015 14:20:04 +0100 Subject: [PATCH] Added get_keys() function --- src/windows.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/windows.rs b/src/windows.rs index 8800c96..52fa9ef 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -297,6 +297,23 @@ impl Window { } } + pub fn get_keys(&self) -> Option> { + let mut index: u16 = 0; + let mut keys: Vec = Vec::new(); + + for i in self.keys.iter() { + if *i { + unsafe { + keys.push(mem::transmute(index as u8)); + } + } + + index += 1; + } + + Some(keys) + } + #[inline] pub fn is_key_down(&self, key: Key) -> bool { return self.keys[key as usize];