buttons

Crates.iobuttons
lib.rsbuttons
version0.5.0
sourcesrc
created_at2019-01-01 11:45:19.420933
updated_at2023-07-22 05:03:23.796374
descriptionA simple API for storing and querying input state.
homepagehttps://github.com/mistodon/buttons
repositoryhttps://github.com/mistodon/buttons
max_upload_size
id104817
size66,026
Vi (mistodon)

documentation

README

buttons

Crates.io Docs.rs

A simple Rust crate for managing and querying input state.

Usage

With 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
    }
});
Commit count: 27

cargo fmt