title: How do I use keyTyped in Java?
body: <p>I used to use the scanner class below to listen for input from the user through the cmd prompt but I am trying to get a Java application to listen for the text by instead using the keyTyped method.</p>
  
  <pre><code>public static void main(String[] args) throws IOException {
      new AsteroidsGame();
      InputStream inputstream = new InputStream() {
  
          @Override
          public int read() throws IOException {
              return 0;
          }
      };
      try {
          FileOutputStream output = new FileOutputStream("HighScore.txt",true);
          Scanner input = new Scanner(System.in);
          PrintStream printStream = new PrintStream(output);
          printStream.println(input.next() + " " + points);
          printStream.close();
          System.out.println("Success!");
      }
      catch(IOException e){
          System.out.println(e);
      }
   }
  </code></pre>
  
  <p>I dont know what to do to the method that will get it to listen for keystrokes and combine the letters into one word. (This is a way of getting a persons name for a game)</p>
  
  <pre><code>@Override
  
  public void keyTyped(KeyEvent e) {      
  if(lives == 0)
      {
          e.getKeyCode() = KeyEvent.???
      }
  }
  </code></pre>
  
  <p>Any suggestions would be appreciated because the Java library and the rest of the Internet has very little to offer in terms of examples or help.</p>