How to close model popup on escape key.
<script type="text/javascript">
jQuery(document).keypress(function(e) {
if (e.keyCode == 27) {
jQuery("#myModal").modal('toggle');
OR
jQuery("#myModal").modal('hide');
}
});
</script>
Note: You can also use keydown() instead of keypress() event.