aboutsummaryrefslogtreecommitdiffstats
path: root/src/key.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/key.rs')
-rw-r--r--src/key.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/key.rs b/src/key.rs
index 8c97ad8..505817f 100644
--- a/src/key.rs
+++ b/src/key.rs
@@ -1,9 +1,12 @@
+/// Type representing a keypress.
#[derive(Eq, PartialEq, Debug, Clone)]
pub enum Key {
String(String),
Char(char),
Bytes(Vec<u8>),
Byte(u8),
+ /// The associated value will be a byte corresponding to the lowercase
+ /// letter for the control code. For instance, `^A` will be `Ctrl(b'a')`.
Ctrl(u8),
Meta(u8),
Backspace,
@@ -22,10 +25,13 @@ pub enum Key {
Delete,
PageUp,
PageDown,
+ /// The associated value will be the number corresponding to the `F` key.
+ /// For instance, `F1` will be `F(1)`.
F(u8),
}
impl Key {
+ /// Returns bytes generated by the given key press.
pub fn into_bytes(self) -> Vec<u8> {
use Key::*;
match self {