Enter/Escape keys to control AlertModal
This commit is contained in:
parent
7f88439c84
commit
bbd6836c68
|
@ -12,6 +12,19 @@ export default {
|
|||
username: '',
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
window.addEventListener('keyup', (e) => {
|
||||
if (!this.visible) return;
|
||||
|
||||
if (e.key === 'Enter') {
|
||||
return this.callback();
|
||||
}
|
||||
|
||||
if (e.key == 'Escape') {
|
||||
return this.close();
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
callback() {
|
||||
this.$emit('close');
|
||||
|
|
Loading…
Reference in New Issue
Block a user