I am developing a simple application, where in, there is no UI involved. My java code will be running as a background process. I want to make the program such that, if the user presses the key anywhere i.e. on any window running on the system, my program will be triggered and it will record the key pressed. In short, I want to listen to 'pure keyboard' without any focus concept getting involved. Is there any way to do so. System.in and other things require focus on UI window.
That's a tough one. It would involve tying into the event processing system of whatever operating system you are running on. That's more difficult to do in a language like Java than a lower level language like C, but it is possible. It would most likely involve using JNI (Java's native interface) and a thorough understanding of the underlying OS. However, there may be pre-written solutions out there yours for a Google search (and possibly some cash).