diff --git a/src/components/CreatePlaylistModal.vue b/src/components/CreatePlaylistModal.vue index 180f162a..43f026f1 100644 --- a/src/components/CreatePlaylistModal.vue +++ b/src/components/CreatePlaylistModal.vue @@ -24,7 +24,19 @@ export default { playlistName: "", }; }, + mounted() { + window.addEventListener("keydown", this.handleKeyDown); + }, + unmounted() { + window.removeEventListener("keydown", this.handleKeyDown); + }, methods: { + handleKeyDown(event) { + if (event.code === "Enter") { + this.onCreatePlaylist(); + event.preventDefault(); + } + }, onCreatePlaylist() { if (!this.playlistName) return; diff --git a/src/components/PlaylistAddModal.vue b/src/components/PlaylistAddModal.vue index 79088bd5..10910b56 100644 --- a/src/components/PlaylistAddModal.vue +++ b/src/components/PlaylistAddModal.vue @@ -65,7 +65,7 @@ export default { }, methods: { handleKeyDown(event) { - if (event.code === "Enter") { + if (event.code === "Enter" && !this.showCreatePlaylistModal) { this.handleClick(this.selectedPlaylist); event.preventDefault(); }