Skip to content

Commit

Permalink
add iopen modal by Enter Space
Browse files Browse the repository at this point in the history
  • Loading branch information
gudzsv committed Feb 8, 2024
1 parent 61bb105 commit 9418426
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ gallery.addEventListener('click', event => {
}
});

document.addEventListener('keydown', event => {
const modal = document.querySelector('.modal');
if (
event.code === 'Enter' ||
event.code === 'NumpadEnter' ||
(event.code === 'Space' && !modal)
) {
openModal(event.target.href);
}
});

function openModal(src) {
const instance = basicLightbox.create(
`
Expand Down

0 comments on commit 9418426

Please sign in to comment.