4 releases

new 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 627/week @ 2020-05-28 848/week @ 2020-06-04 804/week @ 2020-06-11 852/week @ 2020-06-18 1217/week @ 2020-06-25 1028/week @ 2020-07-02 981/week @ 2020-07-09 1265/week @ 2020-07-16 782/week @ 2020-07-23 699/week @ 2020-07-30 1011/week @ 2020-08-06 878/week @ 2020-08-13 970/week @ 2020-08-20 1445/week @ 2020-08-27 811/week @ 2020-09-03 697/week @ 2020-09-10

4,160 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

~140KB