Hi everybody ! I have a jqModal window, and I would like to close it using the ESC key. For that purpose, I assign my modal a keydown() event, and if keyCode == 27, I close the modal.
It works fine, except when I click on another element in the modal first.... I have to press 2 times ESC : the first time removes the focus from the element, the second time goes through my listener and closes the modal. In my modal , I have an ul/li list, each li containing an img (for the purpose of an image gallery). When I click on an image (or li ?), I have to press twice ESC to close the modal. I tried to add a $(this).blur() in the li click() event, and also I tried to put that in the img click event, but without success... Does somebody know why it is doing that, and how to fix it, please ? Thanks a lot !