Skip to content

Commit

Permalink
Added: get_keys_pressed, get_keys_down, get_keys_released
Browse files Browse the repository at this point in the history
  • Loading branch information
alters-mit authored and not-fl3 committed Nov 24, 2023
1 parent db2d267 commit 6d9685d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/input.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Cross-platform mouse, keyboard (and gamepads soon) module.
use std::collections::HashSet;

use crate::get_context;
use crate::prelude::screen_height;
use crate::prelude::screen_width;
Expand Down Expand Up @@ -156,6 +158,21 @@ pub fn get_last_key_pressed() -> Option<KeyCode> {
context.keys_pressed.iter().next().cloned()
}

pub fn get_keys_pressed() -> HashSet<KeyCode> {
let context = get_context();
context.keys_pressed.clone()
}

pub fn get_keys_down() -> HashSet<KeyCode> {
let context = get_context();
context.keys_down.clone()
}

pub fn get_keys_released() -> HashSet<KeyCode> {
let context = get_context();
context.keys_released.clone()
}

/// Clears input queue
pub fn clear_input_queue() {
let context = get_context();
Expand Down

0 comments on commit 6d9685d

Please sign in to comment.