Crates.io | device_query_revamped |
lib.rs | device_query_revamped |
version | 2.2.1 |
source | src |
created_at | 2023-07-27 15:01:38.588716 |
updated_at | 2023-11-04 16:25:05.771657 |
description | A basic library for querying keyboard and mouse state on-demand without a window. |
homepage | https://github.com/bloznelis/device_query |
repository | https://github.com/bloznelis/device_query |
max_upload_size | |
id | 927509 |
size | 62,386 |
It adds the distinction between LMeta and RMeta keys for Linux and Win.
A simple library to query mouse and keyboard inputs on demand without a window. Will work in Windows, Linux on X11, and macOS.
use device_query::{DeviceQuery, DeviceState, MouseState, Keycode};
let device_state = DeviceState::new();
let mouse: MouseState = device_state.get_mouse();
println!("Current Mouse Coordinates: {:?}", mouse.coords);
let keys: Vec<Keycode> = device_state.get_keys();
println!("Is A pressed? {}", keys.contains(Keycode::A));
Windows shouldn't require any special software to be installed for device_query
to work properly.
On Linux, the X11 development libraries are required for device_query
to query state from the OS.
On Ubuntu/Debian:
sudo apt install libx11-dev
On Fedora/RHEL/CentOS:
sudo dnf install xorg-x11-server-devel
On newer versions of MacOS, you may run into issues where you only see meta keys such as shift, backspace, et cetera. This is due to a permission issue. To work around this:
device_query
(such as your terminal) to the list