title: window keypress listener also called on textbox keypress
body: <p>I am new in jquery and javascript. I have a page which has window.keypress event register and a textbox which also has keypress event. on pressing key in textbox both events are called. 1 from textbox keypress and then 2 from window.press. i have tried preventDefault, stopPropagation, stopImmediatePropagation. I want only textbox keypress should be called not the global window.keypress when textbox has focus.
  Can you please guide me how i can prevent window.keypress not to be called.</p>
  <p>Code</p>
  <pre class="lang-js prettyprint-override"><code>function myFunction(e) {
    e.preventDefault();
    var text = $('#close').val();
    if (e.keyCode === 13) {
      if (text.toUpperCase() === &quot;CLOSE&quot;) {
        console.log(&quot;Closed&quot;);
      }
    }
  }
  </code></pre>