Scoop API

scoop:scoop.terminal:0.1.0

src/event/key.scoop

Selected production source · src/event/key.scoop

1package scoop.terminal.event
3/**
4 * A logical key, Unicode scalar, function key, media key, or separately reported modifier key.
5 * Physical-key information depends on the active terminal protocol.
6 */
7public enum KeyCode {
8 /**
9 * The Backspace logical key reported by the terminal.
10 */
11 Backspace,
12 /**
13 * The Enter logical key reported by the terminal.
14 */
15 Enter,
16 /**
17 * The Left logical key reported by the terminal.
18 */
19 Left,
20 /**
21 * The Right logical key reported by the terminal.
22 */
23 Right,
24 /**
25 * The Up logical key reported by the terminal.
26 */
27 Up,
28 /**
29 * The Down logical key reported by the terminal.
30 */
31 Down,
32 /**
33 * The Home logical key reported by the terminal.
34 */
35 Home,
36 /**
37 * The End logical key reported by the terminal.
38 */
39 End,
40 /**
41 * The PageUp logical key reported by the terminal.
42 */
43 PageUp,
44 /**
45 * The PageDown logical key reported by the terminal.
46 */
47 PageDown,
48 /**
49 * The Tab logical key reported by the terminal.
50 */
51 Tab,
52 /**
53 * The backward-tab key report.
54 */
55 BackTab,
56 /**
57 * The Delete logical key reported by the terminal.
58 */
59 Delete,
60 /**
61 * The Insert logical key reported by the terminal.
62 */
63 Insert,
64 /**
65 * A numbered function key.
66 */
67 F(val number: Int),
68 /**
69 * One Unicode scalar delivered as a character key.
70 */
71 Char(val character: Char),
72 /**
73 * A NUL key code.
74 */
75 Null,
76 /**
77 * The Escape key, after any ambiguity delay.
78 */
79 Esc,
80 /**
81 * The CapsLock logical key reported by the terminal.
82 */
83 CapsLock,
84 /**
85 * The ScrollLock logical key reported by the terminal.
86 */
87 ScrollLock,
88 /**
89 * The NumLock logical key reported by the terminal.
90 */
91 NumLock,
92 /**
93 * The PrintScreen logical key reported by the terminal.
94 */
95 PrintScreen,
96 /**
97 * The Pause logical key reported by the terminal.
98 */
99 Pause,
100 /**
101 * The Menu logical key reported by the terminal.
102 */
103 Menu,
104 /**
105 * The keypad center/begin key.
106 */
107 KeypadBegin,
108 /**
109 * A media-control key.
110 */
111 Media(val code: MediaKeyCode),
112 /**
113 * An independently reported modifier key.
114 */
115 Modifier(val code: ModifierKeyCode)
118/**
119 * Distinguishes initial key press, auto-repeat, and release when the protocol reports them.
120 */
121public enum KeyEventKind {
122 /**
123 * The initial press of a key.
124 */
125 Press,
126 /**
127 * An auto-repeat event for a held key.
128 */
129 Repeat,
130 /**
131 * The release of a key.
132 */
133 Release }
135/**
136 * A logical key together with modifiers, press/repeat/release kind, and lock/keypad state.
137 */
138public struct KeyEvent(
139 val code: KeyCode,
140 val modifiers: KeyModifiers = KeyModifiers(),
141 val kind: KeyEventKind = KeyEventKind.Press,
142 val state: KeyEventState = KeyEventState()
145/**
146 * Media playback, track, recording, and volume controls reported as distinct keys.
147 */
148public enum MediaKeyCode {
149 /**
150 * The Play media control.
151 */
152 Play,
153 /**
154 * The Pause media control.
155 */
156 Pause,
157 /**
158 * A combined playback-toggle control.
159 */
160 PlayPause,
161 /**
162 * The Reverse media control.
163 */
164 Reverse,
165 /**
166 * The Stop media control.
167 */
168 Stop,
169 /**
170 * The FastForward media control.
171 */
172 FastForward,
173 /**
174 * The Rewind media control.
175 */
176 Rewind,
177 /**
178 * Advance to the next media track.
179 */
180 TrackNext,
181 /**
182 * Return to the previous media track.
183 */
184 TrackPrevious,
185 /**
186 * The Record media control.
187 */
188 Record,
189 /**
190 * Decrease media volume.
191 */
192 LowerVolume,
193 /**
194 * Increase media volume.
195 */
196 RaiseVolume,
197 /**
198 * Toggle or request muted media volume.
199 */
200 MuteVolume
203/**
204 * Left/right modifier keys and ISO level-shift keys reported independently by enhanced keyboard
205 * protocols.
206 */
207public enum ModifierKeyCode {
208 /**
209 * The left Shift key reported independently of other keys.
210 */
211 LeftShift,
212 /**
213 * The left Control key reported independently of other keys.
214 */
215 LeftControl,
216 /**
217 * The left Alt key reported independently of other keys.
218 */
219 LeftAlt,
220 /**
221 * The left Super key reported independently of other keys.
222 */
223 LeftSuper,
224 /**
225 * The left Hyper key reported independently of other keys.
226 */
227 LeftHyper,
228 /**
229 * The left Meta key reported independently of other keys.
230 */
231 LeftMeta,
232 /**
233 * The right Shift key reported independently of other keys.
234 */
235 RightShift,
236 /**
237 * The right Control key reported independently of other keys.
238 */
239 RightControl,
240 /**
241 * The right Alt key reported independently of other keys.
242 */
243 RightAlt,
244 /**
245 * The right Super key reported independently of other keys.
246 */
247 RightSuper,
248 /**
249 * The right Hyper key reported independently of other keys.
250 */
251 RightHyper,
252 /**
253 * The right Meta key reported independently of other keys.
254 */
255 RightMeta,
256 /**
257 * The ISO level-three shift key.
258 */
259 IsoLevel3Shift,
260 /**
261 * The ISO level-five shift key.
262 */
263 IsoLevel5Shift