Crate bevy_global_input

Source
Expand description

§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

bevybevy_global_input
0.110.4.0
0.100.3.0
0.90.2.0
0.90.1.0

Re-exports§

pub use provide_mki::GlobalHotkeyEvents;
pub use provide_mki::GlobalHotkeys;
pub use provide_mki::GlobalKeyEvents;
pub use provide_mki::GlobalKeys;
pub use provide_mouce::GlobalMouseButtonEvents;
pub use provide_mouce::GlobalMouseEvents;
pub use provide_mouce::GlobalMousePos;
pub use provide_mouce::GlobalScrollEvents;
pub use provide_mouce::MouseControl;

Modules§

provide_mki
Module providing the keyboard events and hotkey handler.
provide_mouce
Module providing the mouse events, position and movements.

Structs§

GlobalInputPlugins
PluginGroup for the mouse and keyboard plugins