Skip to content

mistodon/buttons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
    }
});

About

A Rust crate for managing input state.

Resources

Stars

Watchers

Forks

Packages