Skip to content

Commit

Permalink
πŸ’– Handle Enter key in search
Browse files Browse the repository at this point in the history
  • Loading branch information
nunocoracao committed Dec 14, 2023
1 parent 5cae118 commit 4c41435
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions assets/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ document.addEventListener("keydown", function (event) {
}
}
}

// Enter to get to results
if (event.key == "Enter") {
if (searchVisible && hasResults) {
event.preventDefault();
if (document.activeElement == input) {
first.focus();
} else {
document.activeElement.click();
}
}else{
event.preventDefault();
}
}

});

// Update search on each keypress
Expand Down

0 comments on commit 4c41435

Please sign in to comment.