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

查看:23
本文介绍了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).

您的错误是您访问了错误的文件夹:

/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天全站免登陆