Linux键盘事件捕获/dev/inputX [英] Linux keyboard event capturing /dev/inputX

查看:358
本文介绍了Linux键盘事件捕获/dev/inputX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图捕获键盘事件. 例如我想从头开始细化键盘记录程序. 经过2个小时的战斗,我发现了以下内容

I was trying to capture keyboard events. e.g. I want to drill down a keylogger from the scratch. After 2 hours of fighting I found the following

neel@pc1$ ls -l /dev/input/by-id
lrwxrwxrwx 1 root root 9 2010-05-05 21:33 usb-Plus_More_Enterprise_LTD._USB-compliant_keyboard-event-kbd -> ../event1
lrwxrwxrwx 1 root root 9 2010-05-05 21:33 usb-Plus_More_Enterprise_LTD._USB-compliant_keyboard-event-mouse -> ../event2
lrwxrwxrwx 1 root root 9 2010-05-05 21:33 usb-Plus_More_Enterprise_LTD._USB-compliant_keyboard-mouse -> ../mouse1

但是当我尝试

neel@pc1$ sudo cat /dev/input/usb-Plus_More_Enterprise_LTD._USB-compliant_keyboard-event-kbd

什么都不产生 没有输出

It yields nothing THERE WAS NO OUTPUT

经过更多搜索之后,现在我正在考虑Xorg中的某些内容可能会阻止它.

after a bit more searching Now I am thinking probabbly something in Xorg blocks it.

所以还有更多信息吗? 在说的结尾,我如何从该文件中读取输入? 还是有其他捕获键盘事件的方式?

So Any more Information ?? and atthe end of the say how can I read the input from that file ?? or is there any other way of capturing keyboard events ??

推荐答案

感谢您提供有关ls -l /dev/input/by-id的线索,它对我很有帮助!.

Thank you for the clue about ls -l /dev/input/by-id it helped me a lot !.

defenderdz@defenderdz-pc:~$ ls -l /dev/input/by-id | grep kbd
lrwxrwxrwx 1 root root  9 nov.  28 14:04 usb-Logitech_USB_Receiver-event-kbd -> ../event7
lrwxrwxrwx 1 root root 10 nov.  29 00:33 usb-NOVATEK_USB_Keyboard-event-kbd -> ../event26
lrwxrwxrwx 1 root root  9 nov.  28 14:04 usb-SONiX_USB_DEVICE-event-kbd -> ../event3
defenderdz@defenderdz-pc:~$ 

'kbd'是用于键盘设备的后缀(我连接了3个键盘).

'kbd' is the suffix used for keyboard devices (I have 3 keyboards connected).

您的错误是您正在访问错误的文件夹:

Your error is that you're accessing the wrong folder :

/dev/input/而不是/dev/input/by-id

在我的示例中,正确的路径是:

In my example the correct path is :

defenderdz@defenderdz-pc:~$ sudo cat /dev/input/by-id/usb-NOVATEK_USB_Keyboard-event-kbd
���]�I���]�I���]�Ia���]�b���]�b���]�b���]�����]�����]��s���]����]����]����]�>
���]�>
 ���]�>
d���]�8
       ���]�8
              ���]�8
                    ���]�����]�����]��s���]H|���]H|���]H|���]�����]�� ���]��d���]Ǵ���]Ǵ ���]Ǵ

以您的情况

neel@pc1$ sudo cat /dev/input/by-id/usb-Plus_More_Enterprise_LTD._USB-compliant_keyboard-event-kbd

我并不是说这是最好的解决方案,但对我来说很好. 您甚至可以通过解析ls结果来创建键盘的自动检测...

I'm not saying that it's the best solution but it works fine for me. You can even create an automatic detection of the keyboard by parsing the ls result ...

这篇关于Linux键盘事件捕获/dev/inputX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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