While programming a JavaFX application for the Raspberry Pi 3 using the official JavaFXPorts from Gluon, I encountered the following problem: Pressing the numpad keys on my keyboard doesn't give me any KeyEvent, while on my normal PC it does as it should!
Here's a minimal verifiable example that demonstrates my problem:
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class InputTest extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
Scene s = new Scene(new Group(), 800, 600, Color.ALICEBLUE);
s.setOnKeyPressed((e) -> {
KeyCode code = e.getCode();
System.out.println(code);
if (code.equals(KeyCode.ESCAPE)) {
System.exit(0); // To be able to exit on the RasPi.
}
});
stage.setScene(s);
stage.show();
}
}
Just try pressing the numpad keys, and no events will be fired, while normal keys do work.
Also, it does'nt depend on the numlock state, but my guess would be that my keyboard layout is wrong, maybe?
Any help would be appreciated.
Edit 1:
I have now tested it under the standard out-of-the-box Raspian and Ubuntu 16.04 for the Pi. I doesn't work on both systems, independent of the keyboard layout. In other programs the numpad works as it should.
Cheers