Using Keyboard to Navigate Bootstrap Modal Lightbox

458 Views Asked by At

I'm building a portfolio webpage and have incorporated W3School's Bootstrap Lightbox.

What I am trying to do now is make when you click outside the image, the modal closes; similar to other lightboxes. I also want to add in navigation by using the arrow keys and escape key.

I have searched Stack Overflow and have found questions similar to what I am asking but I do not understand how to add jquery to do what I want. Other lightbox modals work fine when you click outside the box to close it, but why not here? Thank you in advance.

From Bootstrap's page:

$('#myModal').on('hidden.bs.modal', function (e) { // do something... })

What do I put in the // do something..?

0

There are 0 best solutions below