send characters to current window

Before I re-invent the wheel...

I have written an on-screen keyboard & handwriting input client in Java (spare me please, I get paid to write Java and it will take some time to get back up to speed in C & X11).

In order to concentrate on the other bits, I took advantage of a hack that uses the '-text' facility of the estimable XVkbd package to actually send the recognized text to X11. My client does not accept the focus, so the text is sent to the focused window.

The Java client only sends a character, rather than the 'keydown-keyup' pair X11 uses, so Java latency isn't an issue, but I nevertheless get repeat characters - like a key was held down. I'm assuming this is from my misuse of XVkbd, spawned from the Java session.

I can rip up the XVkbd code to make something, but I will feel silly when someone points out that there is already an app or a library call that does this, or could easily be made to do this:

1) Accept a unicode character or string.
2) Put that to the X11 server definitively (little or no lag between 'keydown' and 'keyup').

An existing daemon or library call that can be wrapped with a daemon and spoken to over dbus would be good - something I can 'nice' to -5 perhaps, so that it just happens. User input on a tablet computer (what I'm writing for) isn't likely to be so rapid as to overwhelm the system.

I am aware of the Escher-X11 Java project, and that's no good - it doesn't avoid the possibility that the system will be too busy between times it gets around to running the JVM thread. Definitive at the system level is what's important here, so this aspect can be solved, and I/we can get on with writing Tablet support for Linux/Unix.

Thanks in advance for any help.

Cheers,
Bret