Trap all keys - please help...
Hello:
I am writing a Java application for people with mental disorders. While working with the application, they should be able to press ANY (and I mean ANY) key on the keyboard to move forward. I was able to work it out using KeyListener, however when the user presses Windows key or Sleep key the action associated with them is performed BEFORE I get a keyDown event.
Actually, the dialog is opened on the screen , or Windows Start Dialog, when Windows key is pressed, or Hibernate dialog, when the Sleep key is pressed, and then my application continues to work.
It is very irritating for this kind of users - they just don't know how to close this dialog or what to do at all, and got stuck.
Besides that application works just fine, however we cannot release it with this problem still here.
Is there any way to trap these keys ? I just couldn't find their names for key mapping, I am absolutely clueless.
Any links, samples, ideas - your input is greatly appreciated.
Jose
[1033 byte] By [
chickenmad] at [2007-9-30 20:10:48]

> Thanks you both for answers. What about a platform
> dependent solution ? I can use keyboard hooks on
> Windows,my background is basically c/c++ and I am
> relatively new to Java, so the question is : will such
> "hacker" code compile with Java as a native code ?
I believe (could be wrong, but this is pretty much an educated guess) that even if you were to use the low-level API (SetWindowsHookEx) it still would not "see" certain keystrokes, such as the already-mentioned Ctrl-Alt-Del combo. You're not supposed to be able to, so that it is "guaranteed" that when a user presses that combo, the REAL windows dialog is displayed instead of allowing a hacker to put up a dummy dialog and be able to determine the user's password when he/she typed it into such a dialog box.
> so, no hope :-(((
> Thanks, anyway... I am really new in these forums,
> should I still give dukes for the answer "no, you
> couldn't" ? Just don't know , no offensive ....
Well, what else are you going to do with them? And actually your questions were answered. Give them or retract them, it doesn't really matter much - they're not good for anything really. The main thing is you said "thanks anyway".