In the column
jqgrid contains the jqueryUI DataPicker, which is used in built-in editing mode. If the DataPicker input element has focus and Ctrl + S or some other key is pressed, body_onkeydown is not executed: IE9 calls the default behavior of ctrl + s (save dialog). In FireFox, body_onkeydown also fails.
How to fix this code so that the keys can catch 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 capture the ctrl + s key:
$(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(); }
source share