Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Setting Up A Keylogger In Rust

This does mouse and keyboard

This is straight from the home page example:

Code

use device_query::{DeviceEvents, DeviceState};
fn main() {
    let device_state = DeviceState::new();

    let _guard = device_state.on_mouse_move(|position| {
        println!("Mouse position: {:#?}", position);
    });
    let _guard = device_state.on_mouse_down(|button| {
        println!("Mouse button down: {:#?}", button);
    });
    let _guard = device_state.on_mouse_up(|button| {
        println!("Mouse button up: {:#?}", button);
    });
    let _guard = device_state.on_key_down(|key| {
        println!("Keyboard key down: {:#?}", key);
    });
    let _guard = device_state.on_key_up(|key| {
        println!("Keyboard key up: {:#?}", key);
    });

    loop {}
}

References