xekeys 2.0.0

A simple crate for getting key-presses.
Documentation
  • Coverage
  • 0%
    0 out of 29 items documented0 out of 3 items with examples
  • Size
  • Source code size: 16.89 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.6 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Documentation
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • RustedTerrier

XEKEYS

A simple program to gather key-presses.

Note:

  • None of the mod keys are case sensitive.
  • Ctrl does not work on '-', ';', ''', ',', '.', '[' or '+'.
  • Super only supports arrow keys as I found no way to support regular keys. Any pull requests on this issue would be appreciated.
  • Raw mode is needed for most of the key detection.

Simple example

extern crate xekeys;

use xekeys::{get_keys, Keys};

fn main() {
    loop {
        // Here we get the keypresses as a struct.
        let keys = get_keys();

        // Here we check if q is pressed and control is pressed and if so, we break.
        match keys {
            | Keys::CtrlChar('q') => break,
            | _ => {}
        };
    }
}

Motivation

When I was using termion, I came to the realization that I was unabled to detect ctrl+arrow keys, something I needed. So I made my own crate; but, to justify using this over termion, I added most of the functionality of termion key presses and some extra, such as more modifiers with arrow keys and function keys up to 20.

License

XEKEYS uses BSD-3 clause.

Termion Alternative:

I dont want to make a full termion alternative, termion is already great; but, if you want one, I suggest using this for keypresses, raw_tty for raw mode, lliw for styling, and I guess you can do the cursor movement using ANSI escape codes as well as clearing.

More Info: