Skip to main content

gled_model/input/
key_code.rs

1//! Keyboard keys as gled stores them in projects (tap, blackout and scene
2//! inputs). This mirrors egui's `Key` variant for variant and in the same
3//! order, so projects saved with `egui::Key` load unchanged and sets of input
4//! events keep their order, without the model depending on egui. The
5//! conversions live in `key_code_egui`.
6
7use serde::{Deserialize, Serialize};
8
9#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
10pub enum KeyCode {
11    ArrowDown,
12    ArrowLeft,
13    ArrowRight,
14    ArrowUp,
15    Escape,
16    Tab,
17    Backspace,
18    Enter,
19    Space,
20    Insert,
21    Delete,
22    Home,
23    End,
24    PageUp,
25    PageDown,
26    Copy,
27    Cut,
28    Paste,
29    Colon,
30    Comma,
31    Backslash,
32    Slash,
33    Pipe,
34    Questionmark,
35    Exclamationmark,
36    OpenBracket,
37    CloseBracket,
38    OpenCurlyBracket,
39    CloseCurlyBracket,
40    Backtick,
41    Minus,
42    Period,
43    Plus,
44    Equals,
45    Semicolon,
46    Quote,
47    Num0,
48    Num1,
49    Num2,
50    Num3,
51    Num4,
52    Num5,
53    Num6,
54    Num7,
55    Num8,
56    Num9,
57    A,
58    B,
59    C,
60    D,
61    E,
62    F,
63    G,
64    H,
65    I,
66    J,
67    K,
68    L,
69    M,
70    N,
71    O,
72    P,
73    Q,
74    R,
75    S,
76    T,
77    U,
78    V,
79    W,
80    X,
81    Y,
82    Z,
83    F1,
84    F2,
85    F3,
86    F4,
87    F5,
88    F6,
89    F7,
90    F8,
91    F9,
92    F10,
93    F11,
94    F12,
95    F13,
96    F14,
97    F15,
98    F16,
99    F17,
100    F18,
101    F19,
102    F20,
103    F21,
104    F22,
105    F23,
106    F24,
107    F25,
108    F26,
109    F27,
110    F28,
111    F29,
112    F30,
113    F31,
114    F32,
115    F33,
116    F34,
117    F35,
118    BrowserBack,
119    ShiftLeft,
120    ShiftRight,
121    ControlLeft,
122    ControlRight,
123    AltLeft,
124    AltRight,
125    SuperLeft,
126    SuperRight,
127    IntlBackslash,
128}
129
130impl KeyCode {
131    /// Every key, in declaration order.
132    pub const ALL: &[Self] = &[
133        Self::ArrowDown,
134        Self::ArrowLeft,
135        Self::ArrowRight,
136        Self::ArrowUp,
137        Self::Escape,
138        Self::Tab,
139        Self::Backspace,
140        Self::Enter,
141        Self::Space,
142        Self::Insert,
143        Self::Delete,
144        Self::Home,
145        Self::End,
146        Self::PageUp,
147        Self::PageDown,
148        Self::Copy,
149        Self::Cut,
150        Self::Paste,
151        Self::Colon,
152        Self::Comma,
153        Self::Backslash,
154        Self::Slash,
155        Self::Pipe,
156        Self::Questionmark,
157        Self::Exclamationmark,
158        Self::OpenBracket,
159        Self::CloseBracket,
160        Self::OpenCurlyBracket,
161        Self::CloseCurlyBracket,
162        Self::Backtick,
163        Self::Minus,
164        Self::Period,
165        Self::Plus,
166        Self::Equals,
167        Self::Semicolon,
168        Self::Quote,
169        Self::Num0,
170        Self::Num1,
171        Self::Num2,
172        Self::Num3,
173        Self::Num4,
174        Self::Num5,
175        Self::Num6,
176        Self::Num7,
177        Self::Num8,
178        Self::Num9,
179        Self::A,
180        Self::B,
181        Self::C,
182        Self::D,
183        Self::E,
184        Self::F,
185        Self::G,
186        Self::H,
187        Self::I,
188        Self::J,
189        Self::K,
190        Self::L,
191        Self::M,
192        Self::N,
193        Self::O,
194        Self::P,
195        Self::Q,
196        Self::R,
197        Self::S,
198        Self::T,
199        Self::U,
200        Self::V,
201        Self::W,
202        Self::X,
203        Self::Y,
204        Self::Z,
205        Self::F1,
206        Self::F2,
207        Self::F3,
208        Self::F4,
209        Self::F5,
210        Self::F6,
211        Self::F7,
212        Self::F8,
213        Self::F9,
214        Self::F10,
215        Self::F11,
216        Self::F12,
217        Self::F13,
218        Self::F14,
219        Self::F15,
220        Self::F16,
221        Self::F17,
222        Self::F18,
223        Self::F19,
224        Self::F20,
225        Self::F21,
226        Self::F22,
227        Self::F23,
228        Self::F24,
229        Self::F25,
230        Self::F26,
231        Self::F27,
232        Self::F28,
233        Self::F29,
234        Self::F30,
235        Self::F31,
236        Self::F32,
237        Self::F33,
238        Self::F34,
239        Self::F35,
240        Self::BrowserBack,
241        Self::ShiftLeft,
242        Self::ShiftRight,
243        Self::ControlLeft,
244        Self::ControlRight,
245        Self::AltLeft,
246        Self::AltRight,
247        Self::SuperLeft,
248        Self::SuperRight,
249        Self::IntlBackslash,
250    ];
251}