views:

16

answers:

1

I have a form inside a jQuery UI dialog. The dialog is set to open whenever the "t" key is pressed. The problem is, when this happens, the letter "t" gets inserted into the first input of that dialog's form, which I don't want to happen.

Here's the code I have:

$('#addtime-form').dialog({
  minWidth: 351,
  modal: true,
  autoOpen: false,
  title: 'Add Time',
  resizable: false
});

$(document).keypress(function(e){
  if (e.which == 116 || e.keyCode == 116 || window.event.keyCode == 116) {
    $('#addtime-form').dialog('open');
  };
});
+3  A: 

Try this:

$(document).keypress(function(e){
  if (e.which == 116 || e.keyCode == 116 || window.event.keyCode == 116) {
    e.preventDefault();
    $('#addtime-form').dialog('open');
  };
});
methodin