Capturing Keystrokes in linux. APIs or System calls to capture keyboard strokes
Hello. Me and my team are working on a project which converts English input from a QWERTY keyboard to Unicodes of local Indian languages like Kannada, Tamil etc. Basically, its a language converter. We're using Java and SWT for UI. The program should run in such a way that once the program is running, wherever the user enters, he should be able to see the converted text as output. That is, the program should be able to capture the keystrokes of the active window the user is using. We are developing this software for both windows and linux.
The only solution is using JNI. For that, we need to know linux system calls. Are there APIs in linux to capture key strokes?? I have heard that there are Win32 APIs called WinJooks(not sure) which doesthe job in windows. So wanted to know if something similar is available in linux. Any other way of doing this in java? Any other suggestions regarding this are also welcome. |
I know about this and this keyloggers but they might be buggy,so source code modification may be necessary.A little help for the second one is here.
You can do this on the kernel level also by configuring kernel's keyboard handling code.Here is a good article about that. |
This is simply not a task for Java. Why would you attempt to do this in such a contrived fashion? Use C/C++ and just do it in native code. However, as far as X is concerned, you are lighting a cigarette with a flame thrower.
Take a look at XKB. I know in my Keyboard Indicator in Gnome, I can use the Russian transliterated keyboard by selecting "Russian Phonetic". If I type English 'i', it produces Cyrillic 'и' in the window. So, I assume it would be trivial to do the same for the various other dialects you wish to do. It appears you want to do some sort of transliteration. I would encourage you to just create the keyboard layout and submit this work into XKB upstream. I already noticed Kannada and Tamil there, but not phonetic versions. |
Quote:
Checked out these two links from the linux journal http://www.linuxjournal.com/article/6396 and http://www.linuxjournal.com/article/6429 but i'm yet to figure out how to make use of them. And we need to use Java for development which forces us to use JNI or some other mechanism to interact with C/C++ native code. All we need to do is to output the converted text on to the active window. So capture the key strokes, do the conversion and put it onto the active window. |
All times are GMT -5. The time now is 03:08 AM. |