I have a site which uses heavy key events. For certain actions, it also opens a bootbox confirm box. The confirm box is shown over a transparent layer so all mouse click actions are not executed unless the user clicks on cancel or ok in the bootbox confirm. However I also want it that all keypress events should be disabled when the confirm box is active.
Current I have:
bootbox.confirm('blah blah'? function(yesPlease){
if(yesPlease) {
goAndClimbAVolcano();
}
});
I can wrap this confirm under a disableAllKeyPress()
and enableAllKeyPress()
but I was wondering if there is an easier way to achieve this...
Any pointers are greatly appreciated.
I would use a boolean to lock events. Put a locked=true
just before your confirm message appears, and locked=false
after it closes.
Then you only have to ad if(locked) return;
on your key event functions.
Hope that it helped.
EDIT: I know there are so many ways to do it, I just posted a different one :)