Enter/Escape keys to control AlertModal

This commit is contained in:
Noah 2024-09-18 22:31:58 -07:00
parent 7f88439c84
commit bbd6836c68

View File

@ -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');