buttons 0.1.0

A simple API for storing and querying input state.

buttons

A simple Rust crate for managing and querying input state.

Build Status Crates.io Docs.rs

Usage

With winit

(Enabling the winit-support feature.)

    let mut keyboard = buttons::winit_support::keyboard();
    let mut mouse = buttons::winit_support::mouse();

    {
        let mut keyboard_input = keyboard.begin_frame_input();
        let mut mouse_input = mouse.begin_frame_input();

        events_loop.poll_events(|event| {
            if let Event::WindowEvent { event, .. } = event {
                keyboard_input.handle_event(&event);
                mouse_input.handle_event(&event);
            }
        });
    }

    if keyboard.pressed(VirtualKeyCode::Escape) || mouse.released(MouseButton::Right) {
        ...
    }