Edit this page

Close Dialog on Pressing Enter

Environment

Product Progress Kendo UI Dialog
Operating System All
Browser All
Preferred Language JavaScript

Description

How can I close a Kendo UI Dialog by pressing the Enter key?

Solution

  1. If the Dialog is open, in the handler check attach a keypress handler to the document.
  2. Call its close method.
    <script>
       $(document).ready(function (e) {
            $(document).keypress(function (e) {
                if (e.which == 13) {
                    if ($(".k-dialog").css("display") == "block") {
                        $("#myDialogId").data("kendoDialog").close();
                    }
                }
            });
        });
    });
    </script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy