Add `Key::Quote` (#4683)

* Part of https://github.com/emilk/egui/issues/3653

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

It was surprising to me that this key wasn't sending `Event::Key` events
(only `Event::Text`), so I added a `Key` for it.

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Matt Keeter 2024-06-23 05:36:32 -04:00 committed by GitHub
parent 44f49713eb
commit d7ccf4d341
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -1137,6 +1137,7 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option<egui::Key> {
KeyCode::BracketLeft => Key::OpenBracket,
KeyCode::BracketRight => Key::CloseBracket,
KeyCode::Backquote => Key::Backtick,
KeyCode::Quote => Key::Quote,
KeyCode::Cut => Key::Cut,
KeyCode::Copy => Key::Copy,

View File

@ -73,6 +73,9 @@ pub enum Key {
/// `;`
Semicolon,
/// `'`
Quote,
// ----------------------------------------------
// Digits:
/// `0` (from main row or numpad)
@ -217,6 +220,7 @@ impl Key {
Self::Slash,
Self::Pipe,
Self::Questionmark,
Self::Quote,
// Digits:
Self::Num0,
Self::Num1,
@ -340,6 +344,7 @@ impl Key {
"[" | "OpenBracket" => Self::OpenBracket,
"]" | "CloseBracket" => Self::CloseBracket,
"`" | "Backtick" | "Backquote" | "Grave" => Self::Backtick,
"'" | "Quote" => Self::Quote,
"0" | "Digit0" | "Numpad0" => Self::Num0,
"1" | "Digit1" | "Numpad1" => Self::Num1,
@ -488,6 +493,7 @@ impl Key {
Self::OpenBracket => "OpenBracket",
Self::CloseBracket => "CloseBracket",
Self::Backtick => "Backtick",
Self::Quote => "Quote",
Self::Num0 => "0",
Self::Num1 => "1",