title: How to assign enter key the same function as click?
body: <p>I'm trying to have the <strong>enter key</strong> perform the same task as when a user clicks the button (see jquery). However, when I tried "keyup" and other event handlers, I couldn't get it working correctly. Any ideas on the simpliest way to do this?</p>
  
  <p>Thanks for your patience, and help.</p>
  
  <p>See fiddle: <a href="https://jsfiddle.net/LightYearsAway/qg8f3q37/3/" rel="nofollow">https://jsfiddle.net/LightYearsAway/qg8f3q37/3/</a></p>
  
  <p>HTML</p>
  
  <pre><code>&lt;h3&gt;Needs&lt;/h3&gt;
  &lt;input type="text" id="need-input" placeholder="enter text"&gt;
  &lt;button id="btn1"&gt;Need it!&lt;/button&gt;
  &lt;ul id="need-list"&gt;
      &lt;li&gt;a&lt;/li&gt;
      &lt;li&gt;b&lt;/li&gt;
      &lt;li&gt;c&lt;/li&gt;
      &lt;li&gt;d&lt;/li&gt;
      &lt;li&gt;e&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>$(document).ready(function(){
  
    // click button, add to list
  
    $("#btn1").click(function(){
        $("#need-list").append($("&lt;li&gt;", { text: $("#need-input").val()
        }));
    });
  
    // click list item to hide
  
    $('ul').on('click', 'li', function(event) {
        $(this).slideUp();
    });
  
  });
  </code></pre>