mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-02 04:39:54 -05:00
only apply keybind when visible
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user