only apply keybind when visible

This commit is contained in:
vabene1111
2024-03-06 20:29:41 +01:00
committed by smilerz
parent 44d7f18428
commit fa2fcf4f08

View File

@@ -128,18 +128,20 @@ export default defineComponent({
mounted() {
// add keyhandlers
window.addEventListener('keydown', (e) => {
if (e.key == 'ArrowUp') {
this.selected_result = Math.max(0, this.selected_result - 1)
}
if (e.key == 'ArrowDown') {
this.selected_result = Math.min(this.search_results.length, this.selected_result + 1)
}
if (e.key == 'Enter') {
this.goToSelectedRecipe()
}
if (e.key == 'k' && e.ctrlKey) {
this.dialog = true
e.preventDefault()
if (this.dialog) {
if (e.key == 'ArrowUp') {
this.selected_result = Math.max(0, this.selected_result - 1)
}
if (e.key == 'ArrowDown') {
this.selected_result = Math.min(this.search_results.length, this.selected_result + 1)
}
if (e.key == 'Enter') {
this.goToSelectedRecipe()
}
if (e.key == 'k' && e.ctrlKey) {
this.dialog = true
e.preventDefault()
}
}
})