r/C_Programming • • Jun 03 '26

Question Get ALL keyboard input from Linux?

I'm currently making a program where when a key is pressed on any window or screen, a specific action happens, right now I am reading from /dev/input/event with open() but the problem is

  1. It only reads from a very specific device
  2. It doesn't read from all "keyboards" that I have (I have a laptop keyboard and a wired keyboard) and
  3. Sometimes the main keyboard that I use will just switch up it's number and I have to recompile the thing again

Is there a way to just conveniently get all keyboard input without all this hassle?

10 Upvotes

13 comments sorted by

View all comments

Show parent comment

2

u/Interesting_Debate57 Jun 03 '26

Right. I have a feeling that the abstraction layer between his physical devices and how they're referenced in the OS isn't helping much. Like, to get a physical device renamed you generally have to unplug it, plug something else in, then plug in the original device again.

But I agree, C isn't the issue here; understanding the interface to the OS is the issue.