First of all i want to thank all of you for this amazing project!!
->Both the (jnativehook-2.1.0.jar) and latest night release tested under:
Windows 10 + Java 1.8.0_112 are reporting false Control Key Released inside JavaFX Stage.
The problem
When JavaFX Window is out of focus then it works nicely , but when i focus JavaFX Window i am getting false CTL KEY RELEASED , image below :

Sometimes it works well as you can see and some other times is reporting those false CTRL KEY RELEASED...
The code is below:
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.dispatcher.SwingDispatchService;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
/**
* JavaFXNativeHookExample
*
*/
public class JavaFXNativeHookExample extends Application {
@Override
public void start(final Stage primaryStage) {
final StackPane root = new StackPane();
final Scene scene = new Scene(root, 300, 250);
// Clear previous logging configurations.
LogManager.getLogManager().reset();
// Get the logger for "org.jnativehook" and set the level to off.
Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.OFF);
final Text info = new Text();
root.getChildren().add(info);
try {
GlobalScreen.setEventDispatcher(new SwingDispatchService());
GlobalScreen.registerNativeHook();
} catch (NativeHookException ex) {
System.err.println("There was a problem registering the native hook.");
System.err.println(ex.getMessage());
System.exit(1);
}
GlobalScreen.addNativeKeyListener(new NativeKeyListener() {
public void nativeKeyPressed(NativeKeyEvent e) {
info.setText(NativeKeyEvent.getKeyText(e.getKeyCode()));
System.out.println("Key Pressed: " + NativeKeyEvent.getKeyText(e.getKeyCode()));
}
public void nativeKeyReleased(NativeKeyEvent e) {
System.out.println("Key Released: " + NativeKeyEvent.getKeyText(e.getKeyCode()));
}
public void nativeKeyTyped(NativeKeyEvent e) {
System.out.println("Key Typed: " + NativeKeyEvent.getKeyText(e.getKeyCode()));
}
});
Stage widget = new Stage();
Platform.setImplicitExit(true);
widget.setTitle("JavaFXNativeHook");
widget.initStyle(StageStyle.UTILITY);
widget.initModality(Modality.APPLICATION_MODAL);
widget.setScene(scene);
widget.show();
}
/**
* The main() method is ignored in correctly deployed JavaFX application.
* main() serves only as fallback in case the application can not be
* launched through deployment artifacts, e.g., in IDEs with limited FX
* support. NetBeans ignores main().
*
* @param args
* the command line arguments
*/
public static void main(String[] args) {
/* fix for osx */
System.setProperty("javafx.macosx.embedded", "true");
java.awt.Toolkit.getDefaultToolkit();
/*
* In OSX you must activate accessibility.
*
* To turn it on, type this in Terminal: > sudo touch
* /private/var/db/.AccessibilityAPIEnabled
*
* To then disable it, type this: > sudo rm
* /private/var/db/.AccessibilityAPIEnabled
*/
/* start the app */
launch(args);
}
}
First of all i want to thank all of you for this amazing project!!
->Both the (jnativehook-2.1.0.jar) and latest night release tested under:
Windows 10 + Java 1.8.0_112 are reporting false Control Key Released inside JavaFX Stage.
The problem
When JavaFX Window is out of focus then it works nicely , but when i focus JavaFX Window i am getting false CTL KEY RELEASED , image below :
Sometimes it works well as you can see and some other times is reporting those false CTRL KEY RELEASED...
The code is below: