title: Replace char OnKeyPress
body: <p>I have a textarea input element,</p>
  
  <p>If the user types "@" I want to replace it with @[someTextHere].</p>
  
  <p>I'm using JQuery's keypress event, but I havent been able to get what I want, I keep getting the "@" at the end of the string , I.e. [someTextHere]@.</p>
  
  <p>Is it possible?</p>
  
  <p>My Code:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;textarea id="post-txt"&gt;&lt;/textarea&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;script&gt;
      $('#post-txt').keypress(function(event){
          var str = $('#post-txt').val(); 
  
          if(String.fromCharCode(event.which) == '@'){
              $('#post-txt').val(str.substring(0,str.length) + '[TEXT]'); 
              }
      })  
  &lt;/script&gt;
  </code></pre>
  
  <p>Assistance would be appreciated.</p>