You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I implemented this using assets/js/custom.js but would be nice to move into theme itself:
functionextendSearch(){search_field.addEventListener('keydown',function(e){// Prevent curet from moving when up or down is pressedif(e.keyCode===38||e.keyCode===40||e.keyCode===13){e.preventDefault();return;}});search_field.addEventListener('keyup',function(e){if(e.keyCode!==38&&e.keyCode!==40&&e.keyCode!==13){return}e.preventDefault();varresults=e.target.parentNode.getElementsByClassName('search_result');if(results.length===0){return;}// Find the currently selected result and select the next or previous onevarselected=-1;for(vari=0;i<results.length;i++){if(results[i].classList.contains('active')){selected=i;results[i].classList.remove('active');break;}}if(e.keyCode===38){// For up arrow select the previous resultselected=selected===-1 ? results.length-1 : selected-1;if(selected<0){selected=results.length-1;}results[selected].classList.add('active');return;}elseif(e.keyCode===40){// For down arrow select the next resultselected=selected===-1 ? 0 : selected+1;if(selected===results.length){selected=0;}results[selected].classList.add('active');return;}window.location.href=results[selected===-1 ? 0 : selected].href;return;});}window.addEventListener('load',()=>extendSearch());
The text was updated successfully, but these errors were encountered:
Originally posted by @bb1950328 in #15 (comment)
I implemented this using
assets/js/custom.js
but would be nice to move into theme itself:The text was updated successfully, but these errors were encountered: