title: Disable Alt + F4 for JavaFX
body: <p>I need to disable the close event using <kbd>Alt</kbd> + <kbd>F4</kbd> keyboard shortcut. For now, I'm trying to filter the events in my Scene for this keypress and consume it, but didn't have any success, the close event happens anyway. Follows bellow part of my code:</p>
  
  <pre><code>scene.addEventFilter(KeyEvent.KEY_PRESSED, event -&gt; {
      if (event.isAltDown() &amp;&amp; event.getCode().equals(KeyCode.F4)) {
          event.consume();
      }
  });
  
  primaryStage.setOnCloseRequest((ev) -&gt; System.exit(0));
  </code></pre>