title: Cannot listen to KeyEvent in JavaFX
body: <p>I want my JavaFX program to respond to keyboard events.<br>
  I tried adding listeners to root <code>Pane</code>, to topmost <code>Pane</code>, but it doesn't respond to events!<br>
  Here is my code:</p>
  
  <pre><code>   AnchorPane root = new AnchorPane();
     root.setOnKeyPressed(new EventHandler&lt;KeyEvent&gt;() {
  
          @Override
          public void handle(KeyEvent t) {
              pressKey(t.getCharacter().charAt(0));
          }
      });
      root.setOnKeyReleased(new EventHandler&lt;KeyEvent&gt;() {
  
          @Override
          public void handle(KeyEvent t) {
              releaseKey(t.getCharacter().charAt(0));
          }
      });
      root.addEventHandler(EventType.ROOT, new EventHandler&lt;Event&gt;() {
  
          @Override
          public void handle(Event t) {
              if (t.getClass().equals(KeyEvent.class)) {
                  System.out.println("AAARGH! " + ((KeyEvent)t).getCharacter());
              }
          }
      });
  </code></pre>
  
  <p>WHY U NO WORKING, key events? Am I doing something wrong here?<br>
  To be sure, mouse events works fine with the same code.</p>