Giter VIP home page Giter VIP logo

rawkey's Introduction

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!("");
}

rawkey's People

Contributors

sophiajt avatar hampuslidin avatar fenex avatar

Stargazers

 avatar GAURAV avatar Odin avatar Klas Segeljakt avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

fenex valpackett

rawkey's Issues

Can’t build on AArch32 CPU architecture (Raspberry Pi)

Hi there,

I’m trying to get NuShell working on ARM. This package is listed as a dependency and it doesn’t build on my Raspberry Pi 4 which is running Raspbian 32-bit(armv71/AArch32). This is the error I’m getting.

Compiling rawkey v0.1.2                                                                                                                          
error[E0308]: mismatched types                                                                                                                      
  --> /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/rawkey-0.1.2/src/linux.rs:44:46
   |                                                                                                                                                
44 |             xlib::XQueryKeymap(self.display, keymap);                                                                                          
   |                                              ^^^^^^ expected `u8`, found `i8`
   |                                                                                                                                                
   = note: expected raw pointer `*mut u8`                                                                                                           
              found raw pointer `*mut i8`                                                                                                           
                                                                                                                                                    
error: aborting due to previous error                                                                                                               
                                                                                                                                                    
For more information about this error, try `rustc --explain E0308`.                                                                                 
error: could not compile `rawkey`.                                                                                                                  
                                                                                                                                                    
To learn more, run the command again with --verbose.                                                                                                
warning: build failed, waiting for other jobs to finish...                                                                                          
error: build failed                                    

I found a resolution for a similar issue in remacs/remacs#1393. Could we try that fix here and merge it in?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.