title: How to handle undo/redo event in javascript?
body: <p>I'm trying to detect whenever a form input's value changes using Javascript &amp; JQuery. Unfortunately, I find JQuery's <code>$(elem).change()</code> insufficient because it only fires the change event when <code>elem</code> loses focus. I have to <em>immediately</em> know when there are changes in the form input's value. To this end, I've narrowed down events associated with a possible change in an input's value to <em>keyup</em>, <em>paste</em>, <em>cut</em>, <em>undo</em>, and <em>redo</em>. However, neither javascript nor JQuery seem to have a way of dealing with undo or redo.</p>
  
  <pre><code>var onChange = function ()
  {
      alert('Checking for changes...');
  };
  
  $(this).off('keyup').on('keyup', onChange);
  $(this).off('paste').on('paste', onChange);
  $(this).off('cut').on('cut', onChange);
  
  $(this).off('undo').on('undo', onChange);  // undo ?
  $(this).off('redo').on('redo', onChange);  // redo ?
  </code></pre>
  
  <p>I've googled for undo/redo event in Javascript/JQuery but didn't find anything helpful. Can someone help on how to deal with undo/redo events?</p>