I'm trying to understand how can I get the keyboard inputs without being focused to my JavaFX stage . Usually when I want to get a key input I'm doing this:


public class Controller implements Initializable{

   @FXML
   Button btn ;

   @FXML
   VBox vBox ;

   @Override
   public void initialize(URL location, ResourceBundle resources) {
       vBox.setOnKeyPressed(new EventHandler() {
           @Override
           public void handle(javafx.scene.input.KeyEvent event) {
               System.out.print(event.getCode());
           }
       });
   }

}

But how can I get the input when I'm not focused to my Program ?