title: Using jQuery to listen to keydown event
body: <p>I want to detect when the enter key is pressed, on HTML that will be injected dynamically.</p>
  
  <p>To simply detect when the enter key is pressed, I can do:</p>
  
  <pre><code>$('#textfield').keydown(function (e){
      if(e.keyCode == 13){
          console.log('Enter was pressed');
      }
  })
  </code></pre>
  
  <p>This code works for <code>on()</code>, but I am worried it is inefficient since jQuery will check every time a key is pressed. Is there anything inefficient about this?</p>
  
  <pre><code>$('body').on('keydown','#textfield', function(event) {
    if (event.keyCode == 13) {
      console.log('Enter was pressed');
    }
  }
  </code></pre>