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
/// Mouse button
#[derive(Debug, Clone, Copy)]
#[repr(i32)]
pub enum MouseButton {
/// Left
Left = 0,
/// Middle
Middle = 1,
/// Right
Right = 2,
}
/// Key codes
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(i32)]
pub enum KeyCode {
/// Backspace
Backspace = 0x08,
/// Delete
Delete = 0x2E,
/// Tab
Tab = 0x09,
/// Enter
Enter = 0x0D,
/// PageUp
PageUp = 0x21,
/// PageDown
PageDown = 0x22,
/// End
End = 0x23,
/// Home
Home = 0x24,
/// Arrow left
ArrowLeft = 0x25,
/// Arrow up
ArrowUp = 0x26,
/// Arrow right
ArrowRight = 0x27,
/// Arrow down
ArrowDown = 0x28,
}
impl KeyCode {
pub(crate) fn as_char(&self) -> Option<u16> {
use KeyCode::*;
match self {
Enter => Some(0x0D),
_ => None,
}
}
}
bitflags::bitflags! {
/// Key modifiers for keyboard events.
#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub struct KeyModifier: i32 {
/// Shift key
const SHIFT = 0x1;
/// Control key
const CONTROL = 0x2;
/// Alt key
const ALT = 0x4;
}
}