How can I get my application back to the start menu after pressing ESC
. Currently I can use KeyEvent only when some component is associated, such as TextField
, Button
, etc. I just want to press Esc without any component being selected and the application returns to the main menu. Example of how I do (Associating a component):
txtPesquisar.setOnKeyPressed(k -> {
final KeyCombination ENTER = new KeyCodeCombination(KeyCode.ENTER);
if (ENTER.match(k)) {
atualizar();
}
});