mirror of
https://github.com/Fechin/reference.git
synced 2026-11-20 21:23:11 +03:00
Optimize search modal events
This commit is contained in:
1 parent
993bbcbeab
commit
b3df7f078e
1 file changed
+5
-9
@@ -170,14 +170,6 @@ window.addEventListener('load', () => {
|
||||
_this.openModal(true);
|
||||
});
|
||||
|
||||
document.body.addEventListener('keydown', function (e) {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
|
||||
_this.toggleModal();
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
|
||||
document.body.addEventListener('click', function (e) {
|
||||
if (_this.isOpened()) {
|
||||
if (!_this.box.contains(e.target) && !trigger.contains(e.target)) {
|
||||
@@ -219,8 +211,12 @@ window.addEventListener('load', () => {
|
||||
e.stopPropagation();
|
||||
} else if (e.key === 'Escape') {
|
||||
_this.closeModal();
|
||||
} else if (e.metaKey && e.key === 'k') {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
} else if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
|
||||
_this.toggleModal();
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user