title: jQuery how to get keypress() to listen for any pressed key that isn't what you specify
body: <p>I'm trying to get letters in a word to change color to red when I type and I want them to do it sequentially.  However, I want it so that if someone types in an incorrect letter in that word, the previous letters will lose their color. Here's how it's set up in the HTML file:</p>
  
  <pre><code>&lt;p&gt;Type the &lt;span id="k"&gt;k&lt;/span&gt;&lt;span id="a"&gt;a&lt;/span&gt;&lt;span id="t"&gt;t&lt;/span&gt; keys on your keyboard to change the letters red.&lt;/p&gt;
  </code></pre>
  
  <p>In this example the word is "kat". Each letter changes to red as I type it. However, I want to make it so if I press any key other than "t" after the "ka", then "red" class is removed from "k" and "a".  Is this possible?</p>
  
  <pre><code>    $(document).keypress(function(e) {
      switch(e.which) {
          case 107: $("#k").addClass('red');
      }
  
      if ($("#k").hasClass("red")) {
          switch(e.which) {
              case 97: $("#a").addClass('red');
          }
      }
  
      if ($("#a").hasClass("red")) {
          switch(e.which) {
              case 116: $("#t").addClass('red');
          }
      }
  }); 
  </code></pre>