title: Detecting composed characters to ignore some of them
body: <p>I am writing a contenteditable-based widget which needs to handle text input on its own. It is fairly easy to deal with both ascii and non-ascii characters with something like this:</p>
  
  <pre><code>container_element.addEventListener('keypress', function(event) {
      if (event.ctrlKey || event.altKey || event.metaKey) {
          return;
      }
      if (event.which != 0 &amp;&amp; event.charCode != 0) {
          event.preventDefault();
          var c = String.fromCharCode(event.which);
          handle_character(c);
      }
  });
  </code></pre>
  
  <p>Now, if I configure my local system to input non-ascii characters through dead key composition (say, altgr for example), the above fails miserably. Fancy editors like google docs appear to handle this case quite well across a wide range of OSes and browsers without any need for external plugins so, it is clear that it <em>is</em> possible from the browser-fired events to detect which character is generated from a composition sequence of dead keys. </p>
  
  <p>However, I have been unable to find out how exactly (not even for a single browser/OS combination, say, Chrome/Linux). </p>
  
  <p>Hence my question: would anyone know how to detect which character is being input from a keypress or keydown handler when we are getting a dead-key composition sequence ?</p>