pub enum Event {
KeyPress {
modifiers: Modifiers,
key: KeyInput,
is_repeat: bool,
},
KeyRelease {
modifiers: Modifiers,
key: KeyInput,
},
Mouse {
device_id: u16,
modifiers: Modifiers,
buttons: mmask_t,
x: u32,
y: u32,
},
PasteBegin,
PasteEnd,
Resize {
width: u32,
height: u32,
},
}
Expand description
A single event generated by a terminal. Simple text input, whether arriving via a pipe, a paste command, or typing, will be represented with KeyPress events. These events are inherently lossy and have different levels of support on different terminals. Depending on the use case, certain modifier keys may just never be recorded, key repeats will be indistinguishable from orignal presses, pastes may not be bracketed, and key releases may never be registered, among other failures.
Variants§
KeyPress
A single typing action by the user, input from stdin. Except between PasteBegin and PasteEnd events, these typically will not be control characters, as those are heuristically decoded into modifier keys combined with printable characters.
Fields
KeyRelease
This is kept as a separate event from KeyPress as it usually does not want to be handled in the same way and is supported by very few terminals, making it easy to miss in testing.
Mouse
A motion or click of a mouse button. Modifiers typically are only be available on button state changes, not mouse motion.
PasteBegin
An indication that the following events occur purely as result of the user pasting from some unknown location that should be conservatively considered malicious. Applications should filter out control commands that happen during a paste, only considering the input as raw, unescaped text.
PasteEnd
The marker indicating a return to normal user interaction.
Resize
The window has been resized and the application may want to rerender to fit the new sizee.