bevy: KeyCode::Plus (Minus) not working correctly

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.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

While the “regular” + and the numpad + represent the same character, they are not the same key and as such don’t have the same keycode. Some programs do distinguish between the two. The same applies for all numpad keys. For example in blender the numpad numbers are used to change viewport orientation, while the regular numbers are used for entering real numbers.

Default German Layout, on German Windows 10