chore: enhance modal for esc to close if js is enabled
This commit is contained in:
parent
b7e2eef988
commit
d11d7bed15
5 changed files with 28 additions and 16 deletions
8
src/assets/scripts/modal.js
Normal file
8
src/assets/scripts/modal.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
window.addEventListener('load', () => {
|
||||
const modalInputs = document.querySelectorAll('.modal-input')
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.key === 'Escape') modalInputs.forEach(modalInput => {
|
||||
if (modalInput.checked) modalInput.checked = false
|
||||
})
|
||||
})
|
||||
})
|
Reference in a new issue