diff --git a/src/components/settings/AddKeyBind.vue b/src/components/settings/AddKeyBind.vue index 5050332..2f969e3 100644 --- a/src/components/settings/AddKeyBind.vue +++ b/src/components/settings/AddKeyBind.vue @@ -3,11 +3,13 @@ import AutoComplete from 'primevue/autocomplete' import { HEYNOTE_COMMANDS } from '@/src/editor/commands' + import RecordKeyInput from './RecordKeyInput.vue' export default { name: "AddKeyBind", components: { AutoComplete, + RecordKeyInput, }, data() { return { @@ -34,6 +36,7 @@ mounted() { window.addEventListener("keydown", this.onKeyDown) + this.$refs.keys.$el.focus() }, beforeUnmount() { window.removeEventListener("keydown", this.onKeyDown) @@ -41,7 +44,7 @@ methods: { onKeyDown(event) { - if (event.key === "Escape") { + if (event.key === "Escape" && document.activeElement !== this.$refs.keys.$el) { this.$emit("close") } }, @@ -63,11 +66,18 @@ }, onSave() { + if (this.key === "" || this.command === "") { + return + } this.$emit("save", { key: this.key, command: this.command.name, }) - } + }, + + focusCommandSelector() { + this.$refs.autocomplete.$el.querySelector("input").focus() + }, }, } @@ -80,11 +90,12 @@