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

KeyEvent::text should be None for backspace #3381

Open
rparrett opened this issue Jan 11, 2024 · 7 comments
Open

KeyEvent::text should be None for backspace #3381

rparrett opened this issue Jan 11, 2024 · 7 comments

Comments

@rparrett
Copy link

rparrett commented Jan 11, 2024

Tested Winit 0.29 and bdeb257 with Chrome 120 and Firefox 121.

MacOS 13.6.2 (native) produces Some("\u{8}"), and from a glance at the code, it looks like Windows is probably doing the same. Linux doesn't seem as clear and I'm unable to test.

It would be ideal if this behavior was the same on all platforms.

@kchibisov
Copy link
Member

Use https://docs.rs/winit/latest/winit/keyboard/enum.NamedKey.html#method.to_text if you want text repr of NamedKey.

@rparrett
Copy link
Author

rparrett commented Jan 11, 2024

Okay.

It looks like I may have misread the docs, and the behavior on MacOS is the (and I assume windows) is buggy? KeyEvent::text should only be Some for "real characters"? Am I understanding that right?

My issue is that this behavior is not consistent across platforms.

@daxpedda daxpedda changed the title web: KeyEvent::text is None for backspace KeyEvent::text should be None for backspace Jan 11, 2024
@daxpedda
Copy link
Member

I guess reopening because of platform inconsistencies.

@daxpedda
Copy link
Member

On X11 it seems to be the same issue: pressing backspace returns text: Some("\u{8}").
@kchibisov I'm unsure what the supposed behavior should be at this point, but it seems to me that your initial assessment is correct. Meaning this has to be fixed in apparently most backends.

@kchibisov
Copy link
Member

I guess reopening because of platform inconsistencies.

you can, it's just different issue to the originally reported one.

@kchibisov I'm unsure what the supposed behavior should be at this point, but it seems to me that your initial assessment is correct. Meaning this has to be fixed in apparently most backends.

The issue is a bit more complicated since there's generally no control on how NamedKey values text is filled and the end caveats. Setting always None for it also won't work the way the current input is done, because named key could be at the end of compose input thus it'll have a valid input.

@rparrett
Copy link
Author

rparrett commented Jan 11, 2024

Is there some documentation / standard that is governing this behavior that you can point me to? The distinction between what KeyCode::text and Key::to_text are providing seems arbitrary and confusing.

@kchibisov
Copy link
Member

I'd at least remove text from events having to_text, but I'm not sure how I feel about remove text in general from NamedKey variants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants