-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grab
simulates Enter keypresses on linux x11
#101
Comments
Not sure I understand. You mean the Enter keypress is not ignored ? (Your code is capturing Escape, not Enter, is that it ?) |
Hello and thanks for the speedy response :) The problem is that basically the grab function works and it correctly captures and registers keyboard events (including pressing the |
The problem is that you're using One solution would be something like that: use rdev::{grab, Event, EventType, Key};
use std::process;
fn main() {
println!("Hello, world!");
if let Err(error) = grab(callback) {
println!("Error: {:?}", error)
}
}
static mut STOP: bool = true;
fn callback(event: Event) -> Option<Event> {
unsafe {
println!("Stop {:?}", STOP);
match (STOP, event.event_type) {
(false, key) => {
println!("Keypressed through: {:?}", key);
Some(event)
}
(true, EventType::KeyPress(Key::Escape)) => {
// process::exit(1);
STOP = false;
None
}
(true, EventType::KeyPress(key)) => {
println!("Keypressed: {:?}", key);
None
}
_ => Some(event),
}
}
} If you want to actualy kill the process you need to find a way to do a proper keyboard interrupt or similar. |
I had the same problem: the state of the devices is kept at startup (or something like that). sleep 0.5 ; sudo ./target/debug/psylle I use this workaround here : https://github.com/jersou/mouse-actions/blob/7bd717d32408d1b836e031531f1d051b51957e04/src/main.rs#L33 |
Running
grab
correctly captures KeyEvents globally but it also simulates Enter keypresses globally despite no instructions to do so. Here's the minimum example to reproduce this.With
Linux 6.1.12-arch1-1
rustc 1.60.0 (7737e0b5c 2022-04-04)
The text was updated successfully, but these errors were encountered: