With Twitter Bootstrap modals in either version 2 or 3, you can easily prevent the modal window from being closed with the escape key or by clicking on the black backdrop outside the window.

This is useful for keeping people inside of a wizard or other multi-step process inside of a modal box.

Disable the keyboard (ESC key) and mouse clicks outside window

Adding the attributes of data-keyboard="false" and data-backdrop="static" to your modal div will keep the escape key from closing the window.

Add to HTML element

 
<div id="modal_id" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">

OR control with JavaScript

JAVASCRIPTview code
 
$('#modal_id').modal({ backdrop: 'static', keyboard: true });