Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyCode: Numpad key triggers regular key #1666

Closed
ufReitter opened this issue Mar 16, 2021 · 9 comments
Closed

KeyCode: Numpad key triggers regular key #1666

ufReitter opened this issue Mar 16, 2021 · 9 comments
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Bug An unexpected or incorrect behavior O-MacOS Specific to the MacOS (Apple) desktop operating system

Comments

@ufReitter
Copy link

ufReitter commented Mar 16, 2021

Bevy version

284889c
0.4.0 had the same result

Operating system & version

macOS 11.2.2

What you did

     if keyboard_input.just_pressed(KeyCode::Key5) {
         thruster.thrust = thruster.thrust_max * 1.;
     }

    if keyboard_input.just_pressed(KeyCode::Numpad5) {
        submarine.bow_thruster = 0.;
    }

What you expected to happen

When pressing "5" on Number Pad the second If-Statement is triggered

What actually happened

When pressing "5" on Number Pad only the first If-Statement (Key5) is triggered

@bjorn3 bjorn3 added C-Bug An unexpected or incorrect behavior A-Input Player input via keyboard, mouse, gamepad, and more O-MacOS Specific to the MacOS (Apple) desktop operating system labels Mar 16, 2021
@bjorn3
Copy link
Contributor

bjorn3 commented Mar 16, 2021

Bevy translates straight from winit keyboard events. Winit does support Numpad* events on macOS: https://github.com/rust-windowing/winit/blob/b9f3d333e41464457f6e42640793bf88b9563727/src/platform_impl/macos/event.rs#L176-L186 Does it change when you turn numlock on or off?

@nehalem501
Copy link

nehalem501 commented Mar 17, 2021

Does it change when you turn numlock on or off?

There is no numlock key in macOS if using an Apple keyboard with a numpad (it is always "on").

@bjorn3
Copy link
Contributor

bjorn3 commented Mar 17, 2021

Then I think there is no way to distinguish numpad numbers and non-numpad numbers. Can other programs distinguish between them? For example in Blender the numpad numbers 2, 4, 6 and 8 should change between different view orientations while the non-numpad numbers should be interpreted as regular numbers.

@ufReitter
Copy link
Author

Did not try Blender. But the system distinguishes between numpad and non numpad. When I open the mac virtual keyboard only the regular number keys highlight when pressed and not when pressing the numpad ones. In a text editor the numpad input appears fine.

@bjorn3
Copy link
Contributor

bjorn3 commented Mar 17, 2021

Could you open an issue on winit? https://github.com/rust-windowing/winit/issues/

@mockersf
Copy link
Member

mockersf commented Mar 17, 2021

The scan code is correct, the issue is on the key code

To account for different keyboard layout, winit is attempting to translate the keyboard event to a keycode using the actual character typed, so it can't differentiate between Numpad5 and Key5...

It's done here if you want to open the discussion on winit side - on my azerty layout, this function seems to produce a lot of wrong keycodes

@maroider
Copy link

@mockersf
Copy link
Member

should be fixed by #8745

@alice-i-cecile
Copy link
Member

Resolved upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Bug An unexpected or incorrect behavior O-MacOS Specific to the MacOS (Apple) desktop operating system
Projects
None yet
Development

No branches or pull requests

6 participants