I am displaying a form inside a div tag as a dialog to enter details.
In this form, I want to handle the ESC key using jQuery.
If any input tags have focus, keydown event will trigger. If the focus is on the form but not on any input tags then it will not trigger keydown event.
Here is my code:
$("#NewTicket").keydown(function(e) {
    var unicode = e.keyCode ? e.keyCode : e.charCode
    if (unicode == 27)
    {
        if (confirm("Are you sure you want to cancel?"))
            return true
        else
            return false
    }
});
 
     
     
     
     
    