2021-03-07 22:04:05 +03:00
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
const searchBar = document.getElementById("search-bar");
|
2022-06-10 01:40:49 +03:00
|
|
|
const arrowKeys = [37, 38, 39, 40];
|
|
|
|
let searchValue = searchBar.value;
|
2021-03-07 22:04:05 +03:00
|
|
|
|
2022-06-10 01:40:49 +03:00
|
|
|
searchBar.addEventListener("keyup", function(event) {
|
|
|
|
if (event.keyCode === 13) {
|
2021-03-07 22:04:05 +03:00
|
|
|
document.getElementById("search-form").submit();
|
2022-06-10 01:40:49 +03:00
|
|
|
} else if (searchBar.value !== searchValue && !arrowKeys.includes(event.keyCode)) {
|
|
|
|
searchValue = searchBar.value;
|
|
|
|
handleUserInput();
|
2021-03-07 22:04:05 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|