title: How to trigger jQuery behaviour on click or pressing enter on typeahead.js search results?
body: <p>I have a autocomplete search field (<a href="http://twitter.github.io/typeahead.js/" rel="nofollow">typeahead.js</a>) and I have a behaviour triggered when clicking on a search suggestion ie <code>on click</code>.  </p>
  
  <p>I would like the same behaviour triggered when arrowing down and pressing enter on a suggestion.  </p>
  
  <p>So I would like the behaviour to occur <code>on click</code> or <code>on pressing enter</code>.  </p>
  
  <p>In the example below, I use an input field rather than replicating the full typeahead.js search scenario.  </p>
  
  <p>The problem with the code below is that it is only triggered when pressing enter in the input field (because of the conditional attached to <code>e</code>) and not <code>on click</code>.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;input class="hello" value="hello"&gt;
  </code></pre>
  
  <p><strong>jQuery</strong></p>
  
  <pre><code>$(document).on("click keypress",".hello", function (e) {
  if (e.which == 13) {
  alert($(this).val());
  }
  });
  </code></pre>
  
  <p><strong>jsFiddle</strong></p>
  
  <p><a href="http://jsfiddle.net/rwone/9xhK3/" rel="nofollow">http://jsfiddle.net/rwone/9xhK3/</a></p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Updated jsFiddle with typeahead code:  </p>
  
  <p><a href="http://jsfiddle.net/rwone/9xhK3/10/" rel="nofollow">http://jsfiddle.net/rwone/9xhK3/10/</a></p>