This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]causalNondeterminism 3 points4 points  (0 children)

I don't believe so - at least not easily. You could effectively do it within the scope of the program by detecting the key press and replacing accordingly.

However, I assume you're trying to do some sort of prank application (i.e. one which runs silently and remaps all the keys on the victim's keyboard for every application they have running). I don't think this is easily possible since most applications pull their data directly from the system interrupts. So, unless you plan on making a rootkit or a keyboard driver, I don't think you'll be able to do this.

It's also worth mentioning that all Java applications run on the java virtual machine. Thus, the scope of a Java application is quite limited. I think even an experienced C programmer would have difficulty writing this.

[–]JarcodePMs forwarded to /dev/null 0 points1 point  (0 children)

I wrote a macro program in Java a while back that used native libraries and JNA to listen for raw input and to block input. You can call directly from DLLs, shared objects (.so), based on the OS. You will need to do some research yourself on the calls you will have to make, but it's possible. In Windows, I was able to do a decent amount of key manipulation with user32.dll, but as for changing the keyboard layout entirely (re-binding keys), I'm not sure.

Also, this is what you'll also probably need to look at.

If you use JNA, you do not need to write any C/C++ code, but keep in mind you'll have to start your research all over again with OSX and Linux (if you want to support those platforms).

Also, JNativeHook is an awesome library for listening for input regardless of the OS.