diff --git a/source/js/third-party/search/algolia-search.js b/source/js/third-party/search/algolia-search.js index 10a70c3f12..834920b009 100644 --- a/source/js/third-party/search/algolia-search.js +++ b/source/js/third-party/search/algolia-search.js @@ -114,6 +114,13 @@ document.addEventListener('DOMContentLoaded', () => { }); document.querySelector('.popup-btn-close').addEventListener('click', onPopupClose); document.addEventListener('pjax:success', onPopupClose); + window.addEventListener("keydown", (event) => { + if (event.ctrlKey && event.key === "k") { + event.preventDefault() + document.body.classList.add('search-active'); + setTimeout(() => input.focus(), 500); + } + }); window.addEventListener('keyup', event => { if (event.key === 'Escape') { onPopupClose(); diff --git a/source/js/third-party/search/local-search.js b/source/js/third-party/search/local-search.js index 0bcdeac4d5..f677c0381c 100644 --- a/source/js/third-party/search/local-search.js +++ b/source/js/third-party/search/local-search.js @@ -79,6 +79,14 @@ document.addEventListener('DOMContentLoaded', () => { localSearch.highlightSearchWords(document.querySelector('.post-body')); onPopupClose(); }); + window.addEventListener("keydown", (event) => { + if (event.ctrlKey && event.key === "k") { + event.preventDefault() + document.body.classList.add('search-active'); + setTimeout(() => input.focus(), 500); + if (!localSearch.isfetched) localSearch.fetchData(); + } + }); window.addEventListener('keyup', event => { if (event.key === 'Escape') { onPopupClose();