Crate k_board

source ·
Expand description

crates.io github docs.rs

A lightweight keyboard mannager developed for dynamic programs by listening to keyboard events in raw mode (without the need to press enter). The handler has all the standard events of a western keyboard.

  • Gnu/Linux

§Examples

use k_board::{keyboard::Keyboard, keys::Keys};

fn main() {
   menu(0);
   for key in Keyboard::new() {
       match key {
           Keys::Up => menu(0),
           Keys::Down => menu(1),
           Keys::Enter => break,
           _ => {}
       }
   }
}

fn menu(operation: u8) {
   std::process::Command::new("clear").status().unwrap();
   let mut op: Vec<char> = vec!['*', ' '];
   if operation == 1 {
       op[0] = ' ';
       op[1] = '*';
   }
   println!(
       "[{}] I use k_board lightweight software\n[{}] I use heavyweight software",
       op[0], op[1]
   );
}

Modules§