百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
D

device_query

> 编程语言
开源

一个简单的库,用于在无窗口的情况下查询鼠标和键盘输入。可在 Windows、Linux 和 macOS 中使用。

199 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个简单的库,用于在无窗口的情况下查询鼠标和键盘输入。可在 Windows、Linux 和 macOS 中使用。

device_query

NOTE: This repository has been relocated to https://codeberg.org/ostrosco/device_query. Future work will continue there.

A simple library to query mouse and keyboard inputs on demand without a window. Will work in Windows, Linux on X11, and macOS.

rust
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 = device_state.get_keys();
println!("Is A pressed? {}", keys.contains(Keycode::A));

Dependencies

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:

bash
sudo apt install libx11-dev

On Fedora/RHEL/CentOS:

bash
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:

  • open the MacOS system preferences
  • go to Security -> Privacy
  • scroll down to Accessibility and unlock it
  • add the app that is using device_query (such as your terminal) to the list

Device Callbacks

device_query allows you to register callbacks for various device events such as key presses and mouse movements.

Example

Here's a simple example demonstrating how to use the callback system:

…

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言