add keyup to close modal
This commit is contained in:
parent
230e9e6560
commit
18926dd58a
|
@ -40,6 +40,7 @@
|
|||
hideSettings() { this.active = false },
|
||||
toggleSettings() { this.active = !this.active },
|
||||
keyupListener(e) {
|
||||
if (document.getElementsByClassName('bd-backdrop').length) return;
|
||||
if (this.active && e.which === 27) return this.hideSettings();
|
||||
if (!e.metaKey && !e.ctrlKey || e.key !== 'b') return;
|
||||
this.toggleSettings();
|
||||
|
|
|
@ -44,6 +44,20 @@
|
|||
return {
|
||||
scrolled: false
|
||||
};
|
||||
},
|
||||
beforeMount() {
|
||||
window.addEventListener('keyup', this.keyupListener);
|
||||
},
|
||||
destroyed() {
|
||||
window.removeEventListener('keyup', this.keyupListener);
|
||||
},
|
||||
methods: {
|
||||
keyupListener(e) {
|
||||
console.log('key up!');
|
||||
if (e.which === 27) {
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue