Make ConfirmModal emit confirm if Enter is pressed

This commit is contained in:
Andy Russo 2024-02-19 20:28:56 +05:00
parent c8c1fab373
commit 28dc5abf55

View file

@ -24,5 +24,19 @@ export default {
},
},
emits: ["close", "confirm"],
mounted() {
window.addEventListener("keydown", this.handleKeyDown);
},
unmounted() {
window.removeEventListener("keydown", this.handleKeyDown);
},
methods: {
handleKeyDown(event) {
if (event.code === "Enter") {
this.$emit("confirm");
event.preventDefault();
}
},
},
};
</script>