Linux X11 - Global Keyboard Hook

后端 未结 5 1086
萌比男神i
萌比男神i 2021-01-30 14:26

Is it possible (or how) to create a mechanism (in Linux X11, C++) that works like a global hook in windows (SetWindowsHookEx())?

I would like to be able to catch the key

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 14:41

    Instead of doing this on the X11 level I recommend to do it on the input device level. /dev/input/event give you the input events. You can read off the keypresses there and decide if they should propagate further or be consumed. Unfortunately there's no real documentation for this, but the header file linux/include/input.h is quite self explanatory. Also the evdev maintainer will gladly answer emails.

提交回复
热议问题