title: What is the difference between the document selector and window selector?
body: <p>I have the following JQuery function that takes user input and displays it on screen. When I select for both <code>$(document)</code> and <code>$(window)</code> the function works. What is the disadvantage to using either selector? Where can I read more on these selectors and their differences?</p>
  
  <p>Thank you in advance. </p>
  
  <pre><code>  $(document).keypress(function(e) {
        if(e.keyCode == 13) {
            var id = $("input#example").val()
            console.log(id);
            $('#data').append(id);
        }
    });
  </code></pre>