title: JavaFX - get KeyEvent for non-ASCII characters
body: <p>In  a JavaFX (actually ScalaFX) application, I would like to allow the user to invoke commands by a sequence of keyboard keys. These commands should work regardless of the current keyboard layout (language). for example, the user may be typing in Thai (ภาษา) and then want to save by pressing 'Escape' and than 'S' (or ':' and then 'w', vim style).</p>
  
  <p>I have found that KeyEvents give undefined key code for non-English (non-ASCII?) characters. </p>
  
  <p>This code:</p>
  
  <pre><code>onKeyPressed = (k: KeyEvent) =&gt; {
    println("text: " + k.text + "  " + "code name: " + k.code.name)
  }
  </code></pre>
  
  <p>gives:</p>
  
  <pre><code>text: a  code name: A  
  text:   code name: Alt          &lt;&lt; Alt + Shift switches from English to Hebrew
  text:   code name: Shift  
  text: ש  code name: Undefined  
  </code></pre>
  
  <p>when pressing A, changing language to Hebrew and pressing it again.</p>
  
  <p><strong>How can I overcome this problem?</strong> how can I know which key was pressed regardless of language?</p>
  
  <p>similar unanswered question: <a href="https://stackoverflow.com/questions/14984743/javafx-keyevent-and-accented-characters">JavaFX KeyEvent and accented characters</a></p>