title: jQuery UI modal-dialog: Prevent keypressed when dialog is open
body: <p>I am using jquery-ui modal and my application uses a couple of hotkeys bound to modal-dialogs. </p>
  
  <p>Here is my working <a href="http://jsfiddle.net/NcM9K/4/" rel="nofollow noreferrer">jsfiddle example</a> and code:</p>
  
  <pre><code>$(document).keypress(function(e){console.log("pressed a key: " + e.which);})
  var dialog = $('#modal-dialog')
      .dialog({ modal: true, autoOpen: false, buttons: [{text:"ok"}] });
      .keypress(function(e){console.log("cought!"); e.stopPropagation()})
  $("#bt").click(function(){dialog.dialog("open")})
  </code></pre>
  
  <p>When a modal dialog is open, it is supposed to suppress the keypressed events from traveling up the Dom-tree to the document/window.
  when an input element has focus (does not work with a button) stopPropagation kicks in.
  otherwise however event is propagated.</p>
  
  <p>What is the best way to resolve this?</p>