title: How to capture enter key press for select2
body: <p>I have a select2 dropdown for countries (multiselect). When user types keywords, it shows the related items in the menu.<br>
  For e.g., if user types <em>ind</em>, the menu shows <em>India</em> and <em>Indonesia</em>.
  If the enter key is pressed, the first item (<em>India</em>) is selected. This is the default behavior.</p>
  
  <p>Now, I would like to select both the countries when user types <em>ind</em> and presses enter.</p>
  
  <pre><code>$(".select2-search__field").on("keyup",  function (e) { 
      console.log(e.keyCode);       
      if (e.keyCode == 13) {
          alert();
      }
  });
  </code></pre>
  
  <p>With the above code, the console logs show up for <em>i</em>, <em>n</em> &amp; <em>d</em> but not for the <em>Enter key</em>, and hence the alert never shows.<br>
  I guess the default select2 behavior is preventing my code to be triggered.</p>
  
  <p>What should I do, so that I can capture the enter key press.</p>
  
  <p><a href="https://jsfiddle.net/bwp0svq6/1/" rel="nofollow noreferrer">https://jsfiddle.net/bwp0svq6/1/</a></p>