press_here

Crates.iopress_here
lib.rspress_here
version0.1.2
created_at2025-11-21 00:24:37.973674+00
updated_at2025-11-22 13:17:32.126477+00
descriptionSimple and modular input handling for Bevy
homepage
repositoryhttps://github.com/ad-kr/press_here
max_upload_size
id1942803
size217,129
Adrian Kortyczko (ad-kr)

documentation

README

👉 Press Here 👈

Crates.io docs.rs

press_here provides simple and modular input handling for the Bevy game engine.

Example

Setup is quick and easy. Define axis/trigger and configure bindings:

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Space key or south button on the gamepad for jump
        .add_trigger::<Jump>((KeyCode::Space, GamepadButton::South))
        .add_axis::<Walk>((
            // A/D keys for left/right movement
            Pair(KeyCode::KeyA, KeyCode::KeyD),
            // ..or left stick X-axis with deadzone
            GamepadAxis::LeftStickX.deadzone(0.1),
        ))
        .add_systems(Update, update)
        .run();
}

struct Jump;
struct Walk;

fn update(jump: Res<Trigger<Jump>>, walk: Res<Axis<Walk>>) {
    if jump.just_pressed() {
        jump_character();
    }

    let walk_value = walk.value();
    if walk_value != 0.0 {
        walk_character(walk_value);
    }
}

Super modular

Axis and trigger bindings are modular and can be combined to configure complex input responses. Check out the all_bindings example to see all bindings and modfiers in action.

let binding = Smooth::new(
    (
        Pair(KeyCode::KeyA, KeyCode::KeyD),
        Deadzone(GamepadAxis::LeftStickX, 0.1),
    ),
    0.2,
);

The same binding can be defined using the builder pattern:

let binding = (
    Pair(KeyCode::KeyA, KeyCode::KeyD),
    GamepadAxis::LeftStickX.deadzone(0.1),
)
    .smooth(0.2);

Next steps

  • Better documentation.
    • Currently most structs have some comments and the crate is rather straight forward, but better examples in comments could be provided.
  • Binding information.
    • Add basic info to each binding so that we can know what bindings are set. Right now we would need to iterate over each binding and downcast its type. Not optimal.
  • Observer support.
    • Currently you have to set up event triggering yourself. This can be streamlined.
  • Tests
    • We could write simple unit tests for each binding. Inputs-mocking should be made easier. This would also allow us to make create better doc-comments/tests.
  • Referring to existing axes and triggers.
    • It would be nice to be able to refer to other already defined triggers and axes. This would allow us to do something like .with_trigger::<SomeTrigger>().
  • Schedule configuration.
    • Right now all checks are happending in the PreUpdate schedule. It might be desirable to configure this.
  • Time clock configuration.
    • Currently bindings that rely on time use the Time<Real> clock. If a different clock is desired, we have no way to configure that.
  • ???

Bevy compatibility

Bevy press_here
0.17 0.1
Commit count: 0

cargo fmt