jqgrid column contains jqueryUI DataPicker used in inline edit mode. If DataPicker input element has focus and Ctrl+S or some other key is is pressed, body_onkeydown is not executed: IE9 invokes ctrl+s default behaviour (save dialog). In FireFox body_onkeydown is also not executed.
How to fix this code so keys can catched if DatePicker has focus ?
DatePicker is defined as:
$(elem).datepicker({
dateFormat: 'dd.mm.yy',
autoSize: true,
showOn: 'button',
changeYear: true,
changeMonth: true,
showButtonPanel: true,
showWeek: true
});
Code used to catch ctrl+s keypress is:
$(function () {
$("html").keydown(body_onkeydown);
});
function body_onkeydown(evt) {
// Why this function is not executed if datepicker has focus?
if (evt.ctrlKey) {
switch (evt.keyCode) {
case 83: $("#grid_savebutton").click(); break;
}
cancel(evt);
return false;
}
function cancel(evt) {
evt.returnValue = false;
evt.keyCode = 0;
evt.cancelBubble = true;
evt.preventDefault();
evt.stopPropagation();
}