title: How to Attach onkeypress Event to a Textarea
body: <p><strong>Question Update</strong></p>
  
  <p>How should I check the condition of the <code>if</code> statement using <code>onkeypress</code>? I am using <a href="http://www.smarty.net/docsv2/en/language.function.literal" rel="nofollow">smarty</a> and therefore need the <code>{literal}</code> tags.</p>
  
  <pre><code>{literal}
  if(event.keyCode==13) {
    alert('hi');
  }
  {/literal}
  </code></pre>
  
  <p>Below is an example implementation.</p>
  
  <pre><code>&lt;textarea onkeypress="{literal} if(event.keyCode==13) {alert('hi');} {/literal}" class="fc_tab_txt"&gt;&lt;/textarea&gt;
  </code></pre>