import javafx.event.EventHandler; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import java.util.ArrayList; public class KeyPressHandler implements EventHandler<KeyEvent> { private GameManager manager; private Integer n; private ArrayList<Cage> cages; KeyPressHandler(GameManager manager) { this.manager = manager; this.cages = manager.cages; this.n = manager.getN(); } @Override public void handle(KeyEvent keyEvent) { Cell currentlySelected = manager.getCurrentlySelected(); if (currentlySelected != null) { if (keyEvent.getCode() == KeyCode.ENTER) { manager.getCurrentlySelected().unSelect(); manager.setCurrentlySelected(null); manager.requestFocus(); } } } }