3

I'm looking for a way to intercept all keyboard signals before they reach the active application. I then want to interpret and map the keystrokes before sending them on to the currently active application.

A Python library would be great, but C/C++ would also suffice.

TheEzEzz
  • 177
  • 6
  • You might want to have a look at the implementation of the various screensavers (like xscreensaver) which essentially do the same job when capturing the keyboard input for password entry. – thiton Sep 26 '11 at 20:40

1 Answers1

1

I'm assuming you are using a system with X(org). If not some stuff can be done as well as the evdev level, but that's a another story.

Two parts in your question:

  1. intercepting all key events -> XGrabKeyboard()
  2. sending key events to the active application: I'd use libfakekey, it's a bit hacky hacky (it dynamically remaps part of the current keymap to send the KeySym you want to send) but it worked for me (small tip, don't forget to gerenate both the key presses and key release events :p).

Of course in your application grabbing the keyboard, you will have to listen to the KeyEvents from X and send keys from there.

Damien
  • 206
  • 1
  • 3