How to make all buttons having ActionEvent handler handle Enter key in JavaFX?

Viewed 664

I have about 50 buttons in my application. For all buttons I created handler this way:

@FXML
protected void handleFooButtonActionEvent(ActionEvent actionEvent) {
    ...
}

This way user can press buttons using mouse left button or Space key. However, it is normal practice (as I know) to allow user press button using Enter key. Is it possible to make all buttons having ActionEvent handler (see above) handle also Enter key in JavaFX, for example if we have reference to Stage stage, Scene scene or Parent root?

1 Answers
Related