Skip to content

KeyCode::Plus (Minus) not working correctly #3278

Open
@Halcom1979

Description

@Halcom1979

Bevy version 0.5
Windows 10

What you did

Used following system to zoom in and out. KeyCode::PageDown and PageUp are working. KeyCode::Minus is only working with the normal Minus key, not the one from the NumPad. Also KeyCode::Plus does not work with Plus key or NumPad Plus key. I use a german Keyboard layout.

fn zoom(keyboard_input: Res<Input<KeyCode>>, mut query: Query<(&mut Transform), With<Camera>>) {
    let mut dir = 0.0;
    if keyboard_input.pressed(KeyCode::PageDown) || keyboard_input.pressed(KeyCode::Plus) {
        dir = -0.7;
    }

    if keyboard_input.pressed(KeyCode::PageUp) || keyboard_input.pressed(KeyCode::Minus) {
        dir = 0.7;
    }

    if dir != 0.0 {
        if let Ok(mut transform) = query.single_mut() {
            transform.scale.x += dir * TIME_STEP;
            transform.scale.y += dir * TIME_STEP;
            transform.scale.x = transform.scale.x.clamp(0.5, 2.0);
            transform.scale.y = transform.scale.y.clamp(0.5, 2.0);
        }
    }

    if keyboard_input.pressed(KeyCode::End) {
        if let Ok(mut transform) = query.single_mut() {
            transform.scale.x = 1.0;
            transform.scale.y = 1.0;
        }
    }
}

What you expected to happen

Korrect key recognition.

What actually happened

No or not all key recognitions.

Additional information

Used german Keyboard layout.

Any additional information you would like to add such as screenshots, logs, etc.

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 examplesS-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