Menu accelerator does not work if menu item has been added dynamically, thus, after the stage is shown. I would expect that every time menu item is visible and enabled that it's accelerator will work as well.
Next code snippet can reproduce the issue.
@Override
public void start(Stage stage) throws Exception {
MenuBar menuBar = new MenuBar();
Menu menu = new Menu("Menu");
menuBar.getMenus().addAll(menu);
VBox root = new VBox();
root.getChildren().add(menuBar);
stage.setTitle("Test");
stage.setScene(new Scene(root, 300, 275));
stage.show();
MenuItem menuItem = new MenuItem("Menu A");
menuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+A"));
menuItem.setOnAction(event -> System.out.println("Menu A is selected"));
menu.getItems().add(menuItem);
}
Next code snippet can reproduce the issue.
@Override
public void start(Stage stage) throws Exception {
MenuBar menuBar = new MenuBar();
Menu menu = new Menu("Menu");
menuBar.getMenus().addAll(menu);
VBox root = new VBox();
root.getChildren().add(menuBar);
stage.setTitle("Test");
stage.setScene(new Scene(root, 300, 275));
stage.show();
MenuItem menuItem = new MenuItem("Menu A");
menuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+A"));
menuItem.setOnAction(event -> System.out.println("Menu A is selected"));
menu.getItems().add(menuItem);
}