在Linux C ++上检测keydown和keyup事件 [英] Detecting keydown and keyup events on Linux C++

查看:257
本文介绍了在Linux C ++上检测keydown和keyup事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

在C中访问按键

监控键盘上的键盘Ubuntu

我想检测和时间戳每个keydown和keyup事件程序(是,我的意思是键下键upup 而不仅仅是按键)以及按下什么键。我可以通过使用一个APi如GTK,但我想尽可能简单和低级别,以避免从库影响时间和编写较少的代码的开销。

I want to detect and time stamp every keydown and keyup event in a program (Yes, I mean keydown and keyup not just keypress) along with what key was pressed. I could do this by using an APi such as GTK, but I want to get as simple and low level as possible in order to avoid overhead from the libraries affecting the times as well as writing less code.

我已经搜索了一段时间了,到目前为止已经发现了大量的东西,如何在Windows上做,这不帮助我,因为我使用的是Linux系统,以及如何检测

I have been googling this for a while and so far have found a ton of stuff about how to do it on Windows, which doesn't help me since I am using a Linux system, and how to detect a key press on Linux, but not keyup keydown.

任何人都可以告诉我什么系统调用,库等等,我需要使用以捕获keydown和keyup事件在Linux系统上用C ++的命令行程序?

Can anyone tell me what syscall, library, etc. I would need to use in order to capture the keydown and keyup events on a Linux system with a commandline program in C++? And if you have a link to a tutorial or a code example it would be most appreciated.

推荐答案

实际上,你不是将能够做到这一点没有图书馆。如果您需要的开销很小,我建议您 ncurses 。如果你绝对必须做没有库,看看ncurses如何实现它。这当然会非常复杂。

Realistically, you aren't going to be able to do this without a library. If you want something that has very little overhead, I would suggest ncurses. If you absolutely must do it without a library, look at how ncurses implements it. It will, of course, be very complicated.

这篇关于在Linux C ++上检测keydown和keyup事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆