JDong
JDong

Reputation: 2304

Capturing keyboard input in python as a daemon in Linux

I wanted to know if there were any python modules that allow access to keyboard interrupts non-disruptively. I wanted to make a text-to-speech program, perhaps for the blind programmer out there, and wanted to know how to grab key-presses in real time. There exists things like pyHook for Windows, but what do I use for Linux? Ideally I should be able to get the events such as KB_UP in Windows.

I like orca, but I wanted to design a text-to-speech myself better suited to my needs. If such a thing does not exist for python, what language should I choose to implement such a program? I have heard of pyGame for keyboard input, but I want my program to incur minimal overhead and work in the background.

Upvotes: 3

Views: 2546

Answers (1)

abarnert
abarnert

Reputation: 365717

As usual for linux, there are a variety of different interfaces that can do different parts of what you want on different systems.

I'm guessing what you want is a way to talk to the /dev/input/* interfaces. You can do that just by opening them and ioctling and reading from them, but you probably don't want to do that.

evdev looks like a nice wrapper around both /dev/input/* and the uinput APIs.

Of you could grab pykeylogger and hack up the source to do what you want.

Upvotes: 3

Related Questions