I have a file .fxml
where I have defined a control PasswordField
and an event KeyPressed
:
<PasswordField fx:id="clave" onKeyPressed="#teclaPulsada" prefWidth="170.0" />
I want to avoid having someone paste a copied key and thus force it to be typed. I'm trying with the following code to detect the key control or command (depending on whether it's win or mac) but I do not know how to detect the v key at the same time (control / command + v)
@FXML
void teclaPulsada(KeyEvent keyEvent) {
if (keyEvent.getCode() == KeyCode.COMMAND) {
System.out.println("pulsado command");
keyEvent.consume();
if (keyEvent.getText() == "v") {
System.out.println("pulsada la v");
keyEvent.consume();
}
}
}