3 ms·
It seems to be because of this, any other key closes the modal and resets the hash, and resetting the hash scrolls you up: function closeModal() { le
by franciscop 4y ago
It seems to be because of this, any other key closes the modal and resets the hash, and resetting the hash scrolls you up:
function closeModal() {
let modal = document.getElementById("myModal");
modal.style.display = "none";
window.location.hash = '';
}
// Left and right arrow keys scrub through the gallery.
// Everything else closes the modal.
document.onkeydown = function (e) {
if (e.keyCode === 37) {
// Left arrow
goBackPrevImage();
} else if (e.keyCode === 39) {
// Right arrow
advanceNextImage();
} else {
closeModal();
}
};