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

Add non-portable keys to egui::Key #3303

Closed
timstr opened this issue Sep 5, 2023 · 2 comments · Fixed by #3649
Closed

Add non-portable keys to egui::Key #3303

timstr opened this issue Sep 5, 2023 · 2 comments · Fixed by #3649

Comments

@timstr
Copy link

timstr commented Sep 5, 2023

Currently, the documentation for egui::Key reads:

Many keys are omitted because they are not always physical keys (depending on keyboard language), e.g. ; and §, and are therefore unsuitable as keyboard shortcuts if you want your app to be portable.

I think this is an unfortunate restriction for the case of wanting to develop an app for a limited audience with a known keyboard. I want to be able to assign features to e.g. the / key on my North American keyboard layout to focus to a search bar. I'm unable to, it seems to be implied, because not all keyboard layouts have a slash key. I really appreciate placing portability first but I think the available keys on my actual keyboard should at least come second.

To this end, would it be acceptable to have an API to detect whether any key is physically present? Non-portable keys could be found and queried this way, but non-portable keys should also be included in e.g. the events field of egui::RawInput so that they can be acted on in the same way as existing keys. Appropriate naming and requiring at least some extra typing on the programmer's part would make them think about why they're using non-portable keys and what it means for their audience.

If this approach sounds reasonable, I could try and put in some time to prototype these changes.

Related: #3266

Thanks by the way for this wonderful project! I've really been enjoying it

@ahicks92
Copy link

ahicks92 commented Sep 9, 2023

I was actually coming here to open the same issue in order to frontload a few project ideas I've had, since I need accessibility and Egui is one of the only crates with that. My two use cases:

  • It would be nice to use egui as the "top level" library for games, since I'm blind, I'm writing for other blind people, and getting it nested in anything else accessibly is a whole project.
    • Such games usually use all the keys. Not figuratively. Literally.
  • I'm considering writing a MIDI sequencer. In that use case, . (dotted note) and / (divide the note) etc. are useful. You can think of this as a "text" control except it's not receiving text in the sense of normal text controls, but mnemonics for other things.

Looking at this, it seems we're down at least 9 common keys, namely all punctuation. And though it doesn't matter to me being as it isn't portable even in English layouts, we're also probably down the numpad too.

@emilk
Copy link
Owner

emilk commented Nov 28, 2023

Will be closed by #3649

emilk added a commit that referenced this issue Dec 18, 2023
* Closes #3542
* Closes #2977
* Closes #3303

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants