#mouse-position #mouse-input #mouse #keyboard-events #input #bevy #keyboard-input

bevy_global_input

Global mouse + keyboard input for bevy - doesn't require a focused window

5 releases (3 breaking)

0.4.0 Jul 16, 2023
0.3.0 Mar 6, 2023
0.2.1 Dec 2, 2022
0.2.0 Nov 29, 2022
0.1.0 Nov 23, 2022

#1483 in Game dev

Download history 4/week @ 2024-02-18 6/week @ 2024-02-25 1/week @ 2024-03-03 110/week @ 2024-03-31

110 downloads per month

MIT/Apache

30KB
240 lines

bevy_global_input

Global Mouse and Keyboard events for bevy.

Crates.io Docs.rs

Features

  • Global keyboard events
  • Global mouse position
  • Global Hotkeys
  • Moving the mouse

Not Implemented / TODO

  • Sending Keystrokes
  • Converting to Bevy KeyCode (don't expose underlying library enums)

Quickstart

log out global mouse position every half second.

use std::time::Duration;

use bevy::{prelude::*, time::common_conditions::on_timer};
use bevy_global_input::{GlobalInputPlugins, GlobalMousePos};

fn main() {
    App::new()
        .add_plugins(MinimalPlugins)
        .add_plugins(GlobalInputPlugins)
        .add_systems(
            Update,
            mouse_pos.run_if(on_timer(Duration::from_secs_f32(0.5))),
        );
        // .run();
}

fn mouse_pos(pos: Res<GlobalMousePos>) {
    dbg!(pos);
}

Find more in Examples

compatible bevy versions

bevy bevy_global_input
0.11 0.4.0
0.10 0.3.0
0.9 0.2.0
0.9 0.1.0

Dependencies

~18–29MB
~435K SLoC