New to Kendo UI for jQuery? Start a free 30-day trial
Close Dialog on Pressing Enter
Updated on Dec 10, 2025
Environment
| Product | Progress® Kendo UI® Dialog for jQuery |
| Operating System | All |
| Browser | All |
| Preferred Language | JavaScript |
Description
How can I close a Kendo UI Dialog by pressing the Enter key?
Solution
- If the Dialog is open, in the handler check attach a
keypresshandler to the document. - Call its
closemethod.
<div id='dialog'>My Kendo Dialog</div>
<script>
$(document).ready(function (e) {
$("#dialog").kendoDialog();
});
$(document).keypress(function (e) {
if (e.which == 13) {
if ($(".k-dialog").css("display") == "flex") {
$("#dialog").data("kendoDialog").close();
}
}
});
</script>