Crates.io | buttons |
lib.rs | buttons |
version | 0.5.0 |
source | src |
created_at | 2019-01-01 11:45:19.420933 |
updated_at | 2023-07-22 05:03:23.796374 |
description | A simple API for storing and querying input state. |
homepage | https://github.com/mistodon/buttons |
repository | https://github.com/mistodon/buttons |
max_upload_size | |
id | 104817 |
size | 66,026 |
A simple Rust crate for managing and querying input state.
winit
(Enabling the winit
feature.)
let mut event_loop = winit::event_loop::EventLoop::new();
let mut keyboard = buttons::winit::keyboard();
let mut mouse = buttons::winit::mouse();
let mut touch = buttons::winit::touch();
// Track input
event_loop.run(move |event, _, _| {
keyboard.handle_event(&event);
mouse.handle_event(&event);
touch.handle_event(&event);
// Check state
if keyboard.pressed(VirtualKeyCode::Escape)
|| mouse.released(MouseButton::Right)
|| touch.first_touch().is_some()
{
// Do something
}
});