Skip to content

EventReader<KeyboardInput> triggers events twice on Ubuntu 24.04 #17257

@RobertBrewitz

Description

@RobertBrewitz

Bevy version

0.15.1

Relevant system information

  • rustc 1.82.0 (f6e511eec 2024-10-15)
  • Ubuntu 24.04 LTS

What you did

use bevy::{input::keyboard::KeyboardInput, prelude::*};
use bevy::input::ButtonState;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Update, print_keyboard_event_system)
        .run();
}

fn print_keyboard_event_system(mut keyboard_input_events: EventReader<KeyboardInput>) {
    for event in keyboard_input_events.read() {
        if event.state == ButtonState::Pressed {
            println!("{:?}", event.key_code);
        }
    }
}

What went wrong

Ran the code above and pressed any keyboard button on Ubuntu 24.04 using Bevy 0.15.1, the ButtonState::Pressed event triggers twice.

Additional information

Short discussion on Discord that spawned this issue: https://discord.com/channels/691052431525675048/742569353878437978/1326850835044368467

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-InputPlayer input via keyboard, mouse, gamepad, and moreC-BugAn unexpected or incorrect behaviorD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesO-LinuxSpecific to the Linux desktop operating systemS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions