-3

I have issue in abstract Method releasedKey of Interface NativeKeyListener.

It only captures the key in Case INSENSITIVE Manner(Only Upper Case) but I need it to be Case Sensitive. Besides this the keyTyped method has issues.

Any Solution or Best Alternative of JNativeHook for Java ?

here is my code:

public void nativeKeyReleased(NativeKeyEvent e) {
    if(e.getKeyCode()==NativeKeyEvent.VC_ENTER) 
    { 
        line+="<Pressed ENTER>";   
        System.out.println(line); line=""; 
    } 
    else 
    { 
        line+=NativeKeyEvent.getKeyText(e.getKeyCode()); 
        display(e); 
    } 
}
HDJEMAI
  • 9,436
  • 46
  • 67
  • 93

1 Answers1

0

Although there is no technical limitation, key typed events are always produced on key down so that you receive key typed events during auto repeat. I am not sure why you would want to get the char on release, but if you really need it, you will need buffer the char on key typed and drain the buffer on release. A simple stack should do the trick. Be mindful that all key down events do not produce key typed events. So, push to the stack for key down, pop append the char and push again in typed, then finally pop in key release. This should work as long as your event dispatcher is single threaded.

Alex Barker
  • 4,316
  • 4
  • 28
  • 47