title: Getting input from keyboard using Scanner with JavaFX Stage
body: <p>I have a problem with my application. When I open my application to input my xAxis variable, I have to focus on my "terminal".</p>
  
  <p>What I want to happen is when I'm focused on the Stage, I can still type my variable.</p>
  
  <p>(Where I have highlighted is where I have to focus)
  Screenshot of problem: <a href="http://i.imgur.com/hKqMjoa.png" rel="nofollow">http://i.imgur.com/hKqMjoa.png</a> (I don't have enough Reputation to post a screen shot)</p>
  
  <p>Also some help with the "not responding" might help, but that doesn't affect the program that much.</p>
  
  <p>Code is as follows:</p>
  
  <pre><code>/*
  * To change this template, choose Tools | Templates
  * and open the template in the editor.
  */
  package gamefx;
  
  import java.util.Scanner;
  import javafx.animation.Animation;
  import javafx.animation.AnimationTimer;
  import javafx.animation.TranslateTransition;
  import javafx.application.Application;
  import javafx.geometry.Rectangle2D;
  import javafx.scene.Group;
  import javafx.scene.Scene;
  import javafx.scene.image.Image;
  import javafx.scene.image.ImageView;
  import javafx.scene.layout.StackPane;
  import javafx.scene.paint.Color;
  import javafx.scene.shape.Rectangle;
  import javafx.stage.Stage;
  import javafx.util.Duration;
  
  public class GameFX extends Application { 
  
  public Image img = new Image("Block1.png");
  public ImageView image = new ImageView(img);
  public int yAxis = -300;
  public int xAxis = 0;
  public TranslateTransition  tt = new TranslateTransition(Duration.millis(5000), image);
  public Scanner sn = new Scanner(System.in);
  public String ifelse;
  
  public void spriteAnimation(){
  tt.setByY(yAxis);
  tt.setCycleCount(1);
  tt.play();  
  }
  public void getMove(){
  
  ifelse = sn.nextLine();
  switch (ifelse) {
      case "d":
          rightMove();
          System.out.print("Move Right");
          break;
      case "a":
          leftMove();
          System.out.print("Move left");
          break;
  }
  
  }
  
  public int leftMove(){
  xAxis = -100;
  return xAxis;
  
  }
  public int rightMove(){
  xAxis = 100;
  return xAxis;
  }
  @Override
  public void start(Stage primaryStage) throws InterruptedException{
      primaryStage.setTitle("Game");
  
      StackPane stckp1 = new StackPane();
      Scene scn = new Scene(stckp1, 700, 700);
  
      primaryStage.show();
      getMove();
      stckp1.getChildren().add(image);
      image.setTranslateX(xAxis);
      spriteAnimation();
      primaryStage.setScene(scn);
  
  
  
  }
  
  }
  </code></pre>