LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-08-2009, 03:19 PM   #1
abhinav.zoso
LQ Newbie
 
Registered: Jan 2009
Posts: 14

Rep: Reputation: 0
Question 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.
 
Old 01-08-2009, 05:37 PM   #2
alan_ri
Senior Member
 
Registered: Dec 2007
Location: Croatia
Distribution: Debian GNU/Linux
Posts: 1,733
Blog Entries: 5

Rep: Reputation: 127Reputation: 127
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.
 
Old 01-10-2009, 02:27 AM   #3
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
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.
 
Old 01-10-2009, 11:14 AM   #4
abhinav.zoso
LQ Newbie
 
Registered: Jan 2009
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jcookeman View Post
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.
Thanks. I'm looking at various articles on how to achieve this. I found out a few links which may be useful. I'm looking into it. As you have said, C/C++ is the best way to interact with hardware. That's what i'm looking at. Just wanted to know a way to intercept the key strokes. The other way round is to simple create an editor (which we already have done click here ) which will do the conversion. But this ain't that interactive. There are quite a few softwares which do this in a very nice manner and are very popular (Baraha and Aksharamala (http://code.google.com/p/aksharamala/) ) but they all work in MS Windows. They are IMEs - Input Method Editors. We want to implement a similar software for linux which has not been done so far. So we somehow need to intercept the user key strokes.

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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how does java calls the system calls which are written in c babu198649 Linux - General 3 12-05-2011 03:40 AM
LINUX System calls Jitin Programming 1 08-02-2006 08:47 PM
linux system calls blanny Programming 4 03-04-2006 12:15 AM
some keystrokes of Logitech LX700 Multimedia keyboard not detected vinayreddy Linux - Hardware 0 12-05-2005 09:30 AM
Keyboard lags for 2-4 keystrokes?! gundelgauk Linux - Hardware 1 05-04-2004 11:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration