bones_framework/input/
keyboard.rs

1//! Keyboard input resource.
2
3use crate::prelude::*;
4
5/// Resource containing the keyboard input events detected on the current frame.
6#[derive(HasSchema, Clone, Debug, Default)]
7#[repr(C)]
8pub struct KeyboardInputs {
9    /// The key events that have been detected this frame.
10    pub key_events: SVec<KeyboardEvent>,
11}
12
13/// A keyboard input event.
14#[derive(HasSchema, Clone, Copy, Debug, Default)]
15#[repr(C)]
16pub struct KeyboardEvent {
17    /// The scan code of the pressed key.
18    pub scan_code: u32,
19    /// The key code of the pressed key, if applicable.
20    pub key_code: Maybe<KeyCode>,
21    /// The state of the keyboard button.
22    pub button_state: ButtonState,
23}
24
25/// The key code of a keyboard key.
26#[derive(HasSchema, Clone, Copy, Default, Debug, PartialEq, Eq, Hash)]
27#[repr(u32)]
28pub enum KeyCode {
29    #[default]
30    /// The `1` key over the letters.
31    Key1,
32    /// The `2` key over the letters.
33    Key2,
34    /// The `3` key over the letters.
35    Key3,
36    /// The `4` key over the letters.
37    Key4,
38    /// The `5` key over the letters.
39    Key5,
40    /// The `6` key over the letters.
41    Key6,
42    /// The `7` key over the letters.
43    Key7,
44    /// The `8` key over the letters.
45    Key8,
46    /// The `9` key over the letters.
47    Key9,
48    /// The `0` key over the letters.
49    Key0,
50
51    /// The `A` key.
52    A,
53    /// The `B` key.
54    B,
55    /// The `C` key.
56    C,
57    /// The `D` key.
58    D,
59    /// The `E` key.
60    E,
61    /// The `F` key.
62    F,
63    /// The `G` key.
64    G,
65    /// The `H` key.
66    H,
67    /// The `I` key.
68    I,
69    /// The `J` key.
70    J,
71    /// The `K` key.
72    K,
73    /// The `L` key.
74    L,
75    /// The `M` key.
76    M,
77    /// The `N` key.
78    N,
79    /// The `O` key.
80    O,
81    /// The `P` key.
82    P,
83    /// The `Q` key.
84    Q,
85    /// The `R` key.
86    R,
87    /// The `S` key.
88    S,
89    /// The `T` key.
90    T,
91    /// The `U` key.
92    U,
93    /// The `V` key.
94    V,
95    /// The `W` key.
96    W,
97    /// The `X` key.
98    X,
99    /// The `Y` key.
100    Y,
101    /// The `Z` key.
102    Z,
103
104    /// The `Escape` / `ESC` key, next to the `F1` key.
105    Escape,
106
107    /// The `F1` key.
108    F1,
109    /// The `F2` key.
110    F2,
111    /// The `F3` key.
112    F3,
113    /// The `F4` key.
114    F4,
115    /// The `F5` key.
116    F5,
117    /// The `F6` key.
118    F6,
119    /// The `F7` key.
120    F7,
121    /// The `F8` key.
122    F8,
123    /// The `F9` key.
124    F9,
125    /// The `F10` key.
126    F10,
127    /// The `F11` key.
128    F11,
129    /// The `F12` key.
130    F12,
131    /// The `F13` key.
132    F13,
133    /// The `F14` key.
134    F14,
135    /// The `F15` key.
136    F15,
137    /// The `F16` key.
138    F16,
139    /// The `F17` key.
140    F17,
141    /// The `F18` key.
142    F18,
143    /// The `F19` key.
144    F19,
145    /// The `F20` key.
146    F20,
147    /// The `F21` key.
148    F21,
149    /// The `F22` key.
150    F22,
151    /// The `F23` key.
152    F23,
153    /// The `F24` key.
154    F24,
155
156    /// The `Snapshot` / `Print Screen` key.
157    Snapshot,
158    /// The `Scroll` / `Scroll Lock` key.
159    Scroll,
160    /// The `Pause` / `Break` key, next to the `Scroll` key.
161    Pause,
162
163    /// The `Insert` key, next to the `Backspace` key.
164    Insert,
165    /// The `Home` key.
166    Home,
167    /// The `Delete` key.
168    Delete,
169    /// The `End` key.
170    End,
171    /// The `PageDown` key.
172    PageDown,
173    /// The `PageUp` key.
174    PageUp,
175
176    /// The `Left` / `Left Arrow` key.
177    Left,
178    /// The `Up` / `Up Arrow` key.
179    Up,
180    /// The `Right` / `Right Arrow` key.
181    Right,
182    /// The `Down` / `Down Arrow` key.
183    Down,
184
185    /// The `Back` / `Backspace` key.
186    Back,
187    /// The `Return` / `Enter` key.
188    Return,
189    /// The `Space` / `Spacebar` / ` ` key.
190    Space,
191
192    /// The `Compose` key on Linux.
193    Compose,
194    /// The `Caret` / `^` key.
195    Caret,
196
197    /// The `Numlock` key.
198    Numlock,
199    /// The `Numpad0` / `0` key.
200    Numpad0,
201    /// The `Numpad1` / `1` key.
202    Numpad1,
203    /// The `Numpad2` / `2` key.
204    Numpad2,
205    /// The `Numpad3` / `3` key.
206    Numpad3,
207    /// The `Numpad4` / `4` key.
208    Numpad4,
209    /// The `Numpad5` / `5` key.
210    Numpad5,
211    /// The `Numpad6` / `6` key.
212    Numpad6,
213    /// The `Numpad7` / `7` key.
214    Numpad7,
215    /// The `Numpad8` / `8` key.
216    Numpad8,
217    /// The `Numpad9` / `9` key.
218    Numpad9,
219
220    /// The `AbntC1` key.
221    AbntC1,
222    /// The `AbntC2` key.
223    AbntC2,
224
225    /// The `NumpadAdd` / `+` key.
226    NumpadAdd,
227    /// The `Apostrophe` / `'` key.
228    Apostrophe,
229    /// The `Apps` key.
230    Apps,
231    /// The `Asterisk` / `*` key.
232    Asterisk,
233    /// The `Plus` / `+` key.
234    Plus,
235    /// The `At` / `@` key.
236    At,
237    /// The `Ax` key.
238    Ax,
239    /// The `Backslash` / `\` key.
240    Backslash,
241    /// The `Calculator` key.
242    Calculator,
243    /// The `Capital` key.
244    Capital,
245    /// The `Colon` / `:` key.
246    Colon,
247    /// The `Comma` / `,` key.
248    Comma,
249    /// The `Convert` key.
250    Convert,
251    /// The `NumpadDecimal` / `.` key.
252    NumpadDecimal,
253    /// The `NumpadDivide` / `/` key.
254    NumpadDivide,
255    /// The `Equals` / `=` key.
256    Equals,
257    /// The `Grave` / `Backtick` / `` ` `` key.
258    Grave,
259    /// The `Kana` key.
260    Kana,
261    /// The `Kanji` key.
262    Kanji,
263
264    /// The `Left Alt` key. Maps to `Left Option` on Mac.
265    AltLeft,
266    /// The `Left Bracket` / `[` key.
267    BracketLeft,
268    /// The `Left Control` key.
269    ControlLeft,
270    /// The `Left Shift` key.
271    ShiftLeft,
272    /// The `Left Super` key.
273    /// Generic keyboards usually display this key with the *Microsoft Windows* logo.
274    /// Apple keyboards call this key the *Command Key* and display it using the ⌘ character.
275    #[doc(alias("LWin", "LMeta", "LLogo"))]
276    SuperLeft,
277
278    /// The `Mail` key.
279    Mail,
280    /// The `MediaSelect` key.
281    MediaSelect,
282    /// The `MediaStop` key.
283    MediaStop,
284    /// The `Minus` / `-` key.
285    Minus,
286    /// The `NumpadMultiply` / `*` key.
287    NumpadMultiply,
288    /// The `Mute` key.
289    Mute,
290    /// The `MyComputer` key.
291    MyComputer,
292    /// The `NavigateForward` / `Prior` key.
293    NavigateForward,
294    /// The `NavigateBackward` / `Next` key.
295    NavigateBackward,
296    /// The `NextTrack` key.
297    NextTrack,
298    /// The `NoConvert` key.
299    NoConvert,
300    /// The `NumpadComma` / `,` key.
301    NumpadComma,
302    /// The `NumpadEnter` key.
303    NumpadEnter,
304    /// The `NumpadEquals` / `=` key.
305    NumpadEquals,
306    /// The `Oem102` key.
307    Oem102,
308    /// The `Period` / `.` key.
309    Period,
310    /// The `PlayPause` key.
311    PlayPause,
312    /// The `Power` key.
313    Power,
314    /// The `PrevTrack` key.
315    PrevTrack,
316
317    /// The `Right Alt` key. Maps to `Right Option` on Mac.
318    AltRight,
319    /// The `Right Bracket` / `]` key.
320    BracketRight,
321    /// The `Right Control` key.
322    ControlRight,
323    /// The `Right Shift` key.
324    ShiftRight,
325    /// The `Right Super` key.
326    /// Generic keyboards usually display this key with the *Microsoft Windows* logo.
327    /// Apple keyboards call this key the *Command Key* and display it using the ⌘ character.
328    #[doc(alias("RWin", "RMeta", "RLogo"))]
329    SuperRight,
330
331    /// The `Semicolon` / `;` key.
332    Semicolon,
333    /// The `Slash` / `/` key.
334    Slash,
335    /// The `Sleep` key.
336    Sleep,
337    /// The `Stop` key.
338    Stop,
339    /// The `NumpadSubtract` / `-` key.
340    NumpadSubtract,
341    /// The `Sysrq` key.
342    Sysrq,
343    /// The `Tab` / `   ` key.
344    Tab,
345    /// The `Underline` / `_` key.
346    Underline,
347    /// The `Unlabeled` key.
348    Unlabeled,
349
350    /// The `VolumeDown` key.
351    VolumeDown,
352    /// The `VolumeUp` key.
353    VolumeUp,
354
355    /// The `Wake` key.
356    Wake,
357
358    /// The `WebBack` key.
359    WebBack,
360    /// The `WebFavorites` key.
361    WebFavorites,
362    /// The `WebForward` key.
363    WebForward,
364    /// The `WebHome` key.
365    WebHome,
366    /// The `WebRefresh` key.
367    WebRefresh,
368    /// The `WebSearch` key.
369    WebSearch,
370    /// The `WebStop` key.
371    WebStop,
372
373    /// The `Yen` key.
374    Yen,
375
376    /// The `Copy` key.
377    Copy,
378    /// The `Paste` key.
379    Paste,
380    /// The `Cut` key.
381    Cut,
382}