title: JavaFX key press not captured
body: <p>I am trying to capture key press events (page up and down) but there are no key events received at all. Here is the relevant code:
  Constructor:</p>
  
  <pre><code>private MainLayout() {
      imageView = new ImageView();
      root = new StackPane();
  
      root.getChildren().add(imageView);
      root.setFocusTraversable(true); //no effect
      //root.requestFocus(); //also no effect
      registerEvents();
  
  }
  </code></pre>
  
  <p>Both lines regarding the focus don't have an effect. The stack pane is directly added to scene. 
  There are no other nodes than Scene->StackPane->ImageView.
  I am able to capture key events on the scene, but i need them captured in the stack pane</p>
  
  <p>Here is <code>registerEvents()</code>, all other events are captured fine!:</p>
  
  <pre><code>private void registerEvents() {
      OnScroll onScroll = new OnScroll();
      root.setOnScroll(onScroll);
      OnResize onResize = new OnResize();
      root.heightProperty().addListener(onResize);
      root.widthProperty().addListener(onResize);
      OnMouseDown onMouseDown = new OnMouseDown();
      root.setOnMousePressed(onMouseDown);
      root.setOnMouseReleased((event) -&gt; fitImage());
      root.setOnDragOver((event) -&gt; dragOver(event));
      root.setOnDragDropped((event) -&gt; dropFile(event));
      root.setOnKeyPressed((event) -&gt; {
          LOG.debug("Key captured.");
          if(event.getCode() == KeyCode.PAGE_UP){
              imageView.setImage(ip.prev());
              event.consume();
          } else if(event.getCode() == KeyCode.PAGE_DOWN){
              imageView.setImage(ip.next());
              event.consume();
          }
          if(event.isConsumed()){
              fitImage();
          }
      });
  </code></pre>
  
  <p>I don't see the log out put and a break point is also not caught. So how to catch and handle key events correctly?</p>