4 releases

0.1.3 Sep 14, 2020
0.1.2 Aug 2, 2019
0.1.1 Jul 16, 2019
0.1.0 Jul 16, 2019
Download history 405/week @ 2021-08-11 544/week @ 2021-08-18 560/week @ 2021-08-25 260/week @ 2021-09-01 347/week @ 2021-09-08 512/week @ 2021-09-15 401/week @ 2021-09-22 303/week @ 2021-09-29 223/week @ 2021-10-06 169/week @ 2021-10-13 241/week @ 2021-10-20 197/week @ 2021-10-27 142/week @ 2021-11-03 322/week @ 2021-11-10 166/week @ 2021-11-17 260/week @ 2021-11-24

903 downloads per month
Used in 2 crates (via nu_plugin_binaryview)

MIT license

8KB
152 lines

Early release of a project to support raw key input in terminals. Currently, this supports the following raw keys across the major OSes:

  • LShift - Left Shift (or either Shift on some OSes)
  • LControl - Left Control
  • Back - Backspace
  • Space
  • Tab
  • Escape
  • LeftArrow
  • UpArrow
  • RightArrow
  • DownArrow
  • PageUp
  • PageDown
  • Alt

Rather than using events, rawkey offers a way to scan to see if the key is pressed or not.

use rawkey::{KeyCode, RawKey};

let mut rawkey = RawKey::new();

loop {
    if rawkey.is_pressed(KeyCode::Escape) {
        break;
    }
    if rawkey.is_pressed(KeyCode::UpArrow) {
        print!("Up ");
    }
    if rawkey.is_pressed(KeyCode::DownArrow) {
        print!("Down ");
    }
    if rawkey.is_pressed(KeyCode::LeftArrow) {
        print!("Left ");
    }
    if rawkey.is_pressed(KeyCode::RightArrow) {
        print!("Right ");
    }
    println!("");
}

Dependencies

~145KB