Hi,
We have a need to capture when a user presses "t" when focused on a DatePicker. When they type "t" I need to set the Date on the DatePicker to today's date.
This is essentially a quick shortcut key. Needed because we have Forms with lots of DatePickers and the users will use keyboard only as they tab their way through the form.
I do have a solution, which I worked like this:
$(
"#ExpiryDate"
).kendoDatePicker({
format:
"d"
,
dateInput:
true
});
$(
"#ExpiryDate"
).on(
"keydown"
,
function
(e) {
var
keyCode = e.keyCode || e.which;
if
(keyCode == 84) {
e.preventDefault();
var
picker = $(
this
).data(
"kendoDatePicker"
);
picker.value(
new
Date());
}
else
{
return
;
}
});
However this approach means adding this code snippet for every DatePicker after the initial configuration of the component. And we have content this is loaded on demand, so I can't create all DatePickers on the initial load of the page.
What I'm hoping for is a more generic solution. From what I've read, keydown isn't an event on DatePicker that I can extend.
I was hoping for something like this to work:
var
extendDatePicker = kendo.ui.DatePicker.extend({
keydown:
function
() {
console.log(
"keydown"
);
}
});
But that was wishful thinking.
If anyone has a solution, I'd appreciate it :)
Thanks