-
Notifications
You must be signed in to change notification settings - Fork 0
/
key.ml
75 lines (73 loc) · 1017 Bytes
/
key.ml
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
type code =
| Char of int
| Enter
| Escape
| Tab
| Up
| Down
| Left
| Right
| F1
| F2
| F3
| F4
| F5
| F6
| F7
| F8
| F9
| F10
| F11
| F12
| Next_page
| Prev_page
| Home
| End
| Insert
| Delete
| Backspace
| PageUp
| PageDown
| PrintScrn
| Esc
type t = {
control : bool;
meta : bool;
shift : bool;
code : code;
}
let compare = compare
let of_code = function
| 3 -> Enter
| 8 -> Backspace
| 9 -> Tab
| 13 -> Enter
(* | 16 -> Shift *)
(* | 17 -> Ctrl *)
(* | 18 -> Alt *)
(* | 19 -> Pause *)
(* | 20 -> CapsLock *)
| 27 -> Esc
| 33 -> PageUp
| 34 -> PageDown
| 35 -> End
| 36 -> Home
| 37 -> Left
| 38 -> Up
| 39 -> Right
| 40 -> Down
| 44 -> PrintScrn
| 45 -> Insert
| 46 -> Delete
| 127 -> Delete
| 63232 -> Up
| 63233 -> Down
| 63234 -> Left
| 63235 -> Right
| 63272 -> Delete
| 63273 -> Home
| 63275 -> End
| 63276 -> PageUp
| 63277 -> PageDown
| 63302 -> Insert
| n -> Char n