keyfn-closures

Crates.iokeyfn-closures
lib.rskeyfn-closures
version0.2.1
sourcesrc
created_at2023-02-05 23:17:50.271793
updated_at2023-02-05 23:17:50.271793
descriptioncall function on keypress/release
homepagehttps://github.com/gboncoffee/keyfn-closures
repositoryhttps://github.com/gboncoffee/keyfn-closures
max_upload_size
id777506
size10,540
96 (gboncoffee)

documentation

README

keyfn-closures

Bind key events (press/release) to closures in rust using xlib. Supports same key with different modifier.

This is a fork from the crate keyfn by einzigartigerName.

Usage

Add this to your Cargo.toml

[dependencies]
keyfn-closures = "0.2.1"

Example

extern crate keyfn;

use keyfn::*;

fn main(){
    // create new KeyStorage
    let mut storage = KeyStorage::new();

    // Call crtl-a_pressed when Control + a is pressed
    let ctrl_a = KeyBind::new(
        keysym::XK_a,
        vec![Mod::Control],
        Trigger::Pressed,
        ctrl_a_pressed,
    );
    
    // Add KeyBind to storage
    storage.add(ctrl_a);

    // start storage
    storage.start();
}

fn ctrl_a_pressed(){
    println!("Control + A pressed!");
}
Commit count: 0

cargo fmt