gluten_keyboard/lib.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479
// Generated by gluten-keyboard-generator, and is dual licensed under the MIT and Apache2 Licenses
#![no_std]
//! Provides an enum containing keys found on most keyboards. Useful for implementing a system where the user
//! needs to handle keyboard input. Made because I couldn't find a useful standard that didn't pretend everything
//! used `char`.
/// A set of keys.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Key {
/// The Unknown key.
Unknown,
/// The Zero (0) key.
Zero,
/// The One (1) key.
One,
/// The Two (2) key.
Two,
/// The Three (3) key.
Three,
/// The Four (4) key.
Four,
/// The Five (5) key.
Five,
/// The Six (6) key.
Six,
/// The Seven (7) key.
Seven,
/// The Eight (8) key.
Eight,
/// The Nine (9) key.
Nine,
/// The A (A) key.
A,
/// The B (B) key.
B,
/// The C (C) key.
C,
/// The D (D) key.
D,
/// The E (E) key.
E,
/// The F (F) key.
F,
/// The G (G) key.
G,
/// The H (H) key.
H,
/// The I (I) key.
I,
/// The J (J) key.
J,
/// The K (K) key.
K,
/// The L (L) key.
L,
/// The M (M) key.
M,
/// The N (N) key.
N,
/// The O (O) key.
O,
/// The P (P) key.
P,
/// The Q (Q) key.
Q,
/// The R (R) key.
R,
/// The S (S) key.
S,
/// The T (T) key.
T,
/// The U (U) key.
U,
/// The V (V) key.
V,
/// The W (W) key.
W,
/// The X (X) key.
X,
/// The Y (Y) key.
Y,
/// The Z (Z) key.
Z,
/// The Accept key.
Accept,
/// The Add key.
Add,
/// The Again key.
Again,
/// The AllCandidates key.
AllCandidates,
/// The Alphanumeric key.
Alphanumeric,
/// The Alt key.
Alt,
/// The AltGraph key.
AltGraph,
/// The Ampersand (&) key.
Ampersand,
/// The Asterisk (*) key.
Asterisk,
/// The BackQuote key.
BackQuote,
/// The BackSlash (\) key.
BackSlash,
/// The Begin key.
Begin,
/// The BraceLeft ({) key.
BraceLeft,
/// The BraceRight (}) key.
BraceRight,
/// The Cancel key.
Cancel,
/// The CapsLock key.
CapsLock,
/// The Circumflex (^) key.
Circumflex,
/// The Clear key.
Clear,
/// The BracketLeft ([) key.
BracketLeft,
/// The BracketRight (]) key.
BracketRight,
/// The CodeInput key.
CodeInput,
/// The Colon (:) key.
Colon,
/// The Comma (,) key.
Comma,
/// The Compose key.
Compose,
/// The ContextMenu key.
ContextMenu,
/// The LeftControl key.
LeftControl,
/// The RightControl key.
RightControl,
/// The Convert key.
Convert,
/// The Copy key.
Copy,
/// The Cut key.
Cut,
/// The Decimal key.
Decimal,
/// The Delete key.
Delete,
/// The Divide key.
Divide,
/// The Dollar ($) key.
Dollar,
/// The Down key.
Down,
/// The End key.
End,
/// The Enter key.
Enter,
/// The Equals (=) key.
Equals,
/// The Escape key.
Escape,
/// The EuroSign (€) key.
EuroSign,
/// The ExclamationMark (!) key.
ExclamationMark,
/// The F1 key.
F1,
/// The F2 key.
F2,
/// The F3 key.
F3,
/// The F4 key.
F4,
/// The F5 key.
F5,
/// The F6 key.
F6,
/// The F7 key.
F7,
/// The F8 key.
F8,
/// The F9 key.
F9,
/// The F10 key.
F10,
/// The F11 key.
F11,
/// The F12 key.
F12,
/// The F13 key.
F13,
/// The F14 key.
F14,
/// The F15 key.
F15,
/// The F16 key.
F16,
/// The F17 key.
F17,
/// The F18 key.
F18,
/// The F19 key.
F19,
/// The F20 key.
F20,
/// The F21 key.
F21,
/// The F22 key.
F22,
/// The F23 key.
F23,
/// The F24 key.
F24,
/// The Final key.
Final,
/// The Find key.
Find,
/// The FullWidth key.
FullWidth,
/// The Greater (>) key.
Greater,
/// The HalfWidth key.
HalfWidth,
/// The Help key.
Help,
/// The Hiragana key.
Hiragana,
/// The Home key.
Home,
/// The InputMethodOnOff key.
InputMethodOnOff,
/// The Insert key.
Insert,
/// The InvertedExclamationMark (¡) key.
InvertedExclamationMark,
/// The JapaneseHiragana key.
JapaneseHiragana,
/// The JapaneseKatakana key.
JapaneseKatakana,
/// The JapaneseRoman key.
JapaneseRoman,
/// The Kana key.
Kana,
/// The KanaLock key.
KanaLock,
/// The KpLeft key.
KpLeft,
/// The KpDown key.
KpDown,
/// The KpRight key.
KpRight,
/// The KpUp key.
KpUp,
/// The Left key.
Left,
/// The ParenthesisLeft (() key.
ParenthesisLeft,
/// The ParenthesisRight ()) key.
ParenthesisRight,
/// The Less (<) key.
Less,
/// The Meta key.
Meta,
/// The Minus (-) key.
Minus,
/// The ModeChange key.
ModeChange,
/// The Multiply key.
Multiply,
/// The DontConvert key.
DontConvert,
/// The NumLock key.
NumLock,
/// The NumberSign (#) key.
NumberSign,
/// The NumpadZero (0) key.
NumpadZero,
/// The NumpadOne (1) key.
NumpadOne,
/// The NumpadTwo (2) key.
NumpadTwo,
/// The NumpadThree (3) key.
NumpadThree,
/// The NumpadFour (4) key.
NumpadFour,
/// The NumpadFive (5) key.
NumpadFive,
/// The NumpadSix (6) key.
NumpadSix,
/// The NumpadSeven (7) key.
NumpadSeven,
/// The NumpadEight (8) key.
NumpadEight,
/// The NumpadNine (9) key.
NumpadNine,
/// The PageDown key.
PageDown,
/// The PageUp key.
PageUp,
/// The Paste key.
Paste,
/// The Pause key.
Pause,
/// The Period (.) key.
Period,
/// The Plus (+) key.
Plus,
/// The PreviousCandidate key.
PreviousCandidate,
/// The Props key.
Props,
/// The Quote (') key.
Quote,
/// The DoubleQuote (") key.
DoubleQuote,
/// The Right key.
Right,
/// The RomanCharacters key.
RomanCharacters,
/// The ScrollLock key.
ScrollLock,
/// The Separator key.
Separator,
/// The LeftShift key.
LeftShift,
/// The RightShift key.
RightShift,
/// The ShiftLock key.
ShiftLock,
/// The LeftMeta key.
LeftMeta,
/// The RightMeta key.
RightMeta,
/// The LeftAlt key.
LeftAlt,
/// The RightAlt key.
RightAlt,
/// The LeftSuper key.
LeftSuper,
/// The RightSuper key.
RightSuper,
/// The LeftHyper key.
LeftHyper,
/// The RightHyper key.
RightHyper,
/// The Slash (/) key.
Slash,
/// The Space ( ) key.
Space,
/// The Stop key.
Stop,
/// The Subtract key.
Subtract,
/// The Tab key.
Tab,
/// The Underscore (_) key.
Underscore,
/// The Undo key.
Undo,
/// The Up key.
Up,
/// The Windows key.
Windows,
/// The Percent (%) key.
Percent,
/// The Question (?) key.
Question,
/// The At (@) key.
At,
/// The Tilde (~) key.
Tilde,
/// The Semicolon (;) key.
Semicolon,
/// The Backquote (`) key.
Backquote,
/// The Bar (|) key.
Bar,
/// The Backspace key.
Backspace,
}
impl Default for Key {
#[inline]
fn default() -> Self {
Self::Unknown
}
}
impl Key {
#[inline]
pub fn as_char(self) -> Option<char> {
match self {
Key::Zero => Some('\u{30}'),
Key::One => Some('\u{31}'),
Key::Two => Some('\u{32}'),
Key::Three => Some('\u{33}'),
Key::Four => Some('\u{34}'),
Key::Five => Some('\u{35}'),
Key::Six => Some('\u{36}'),
Key::Seven => Some('\u{37}'),
Key::Eight => Some('\u{38}'),
Key::Nine => Some('\u{39}'),
Key::A => Some('\u{41}'),
Key::B => Some('\u{42}'),
Key::C => Some('\u{43}'),
Key::D => Some('\u{44}'),
Key::E => Some('\u{45}'),
Key::F => Some('\u{46}'),
Key::G => Some('\u{47}'),
Key::H => Some('\u{48}'),
Key::I => Some('\u{49}'),
Key::J => Some('\u{4a}'),
Key::K => Some('\u{4b}'),
Key::L => Some('\u{4c}'),
Key::M => Some('\u{4d}'),
Key::N => Some('\u{4e}'),
Key::O => Some('\u{4f}'),
Key::P => Some('\u{50}'),
Key::Q => Some('\u{51}'),
Key::R => Some('\u{52}'),
Key::S => Some('\u{53}'),
Key::T => Some('\u{54}'),
Key::U => Some('\u{55}'),
Key::V => Some('\u{56}'),
Key::W => Some('\u{57}'),
Key::X => Some('\u{58}'),
Key::Y => Some('\u{59}'),
Key::Z => Some('\u{5a}'),
Key::Ampersand => Some('\u{26}'),
Key::Asterisk => Some('\u{2a}'),
Key::BackSlash => Some('\u{5c}'),
Key::BraceLeft => Some('\u{7b}'),
Key::BraceRight => Some('\u{7d}'),
Key::Circumflex => Some('\u{5e}'),
Key::BracketLeft => Some('\u{5b}'),
Key::BracketRight => Some('\u{5d}'),
Key::Colon => Some('\u{3a}'),
Key::Comma => Some('\u{2c}'),
Key::Dollar => Some('\u{24}'),
Key::Equals => Some('\u{3d}'),
Key::EuroSign => Some('\u{20ac}'),
Key::ExclamationMark => Some('\u{21}'),
Key::Greater => Some('\u{3e}'),
Key::InvertedExclamationMark => Some('\u{a1}'),
Key::ParenthesisLeft => Some('\u{28}'),
Key::ParenthesisRight => Some('\u{29}'),
Key::Less => Some('\u{3c}'),
Key::Minus => Some('\u{2d}'),
Key::NumberSign => Some('\u{23}'),
Key::NumpadZero => Some('\u{30}'),
Key::NumpadOne => Some('\u{31}'),
Key::NumpadTwo => Some('\u{32}'),
Key::NumpadThree => Some('\u{33}'),
Key::NumpadFour => Some('\u{34}'),
Key::NumpadFive => Some('\u{35}'),
Key::NumpadSix => Some('\u{36}'),
Key::NumpadSeven => Some('\u{37}'),
Key::NumpadEight => Some('\u{38}'),
Key::NumpadNine => Some('\u{39}'),
Key::Period => Some('\u{2e}'),
Key::Plus => Some('\u{2b}'),
Key::Quote => Some('\u{27}'),
Key::DoubleQuote => Some('\u{22}'),
Key::Slash => Some('\u{2f}'),
Key::Space => Some('\u{20}'),
Key::Underscore => Some('\u{5f}'),
Key::Percent => Some('\u{25}'),
Key::Question => Some('\u{3f}'),
Key::At => Some('\u{40}'),
Key::Tilde => Some('\u{7e}'),
Key::Semicolon => Some('\u{3b}'),
Key::Backquote => Some('\u{60}'),
Key::Bar => Some('\u{7c}'),
_ => None,
}
}
}