Created
May 10, 2021 21:41
-
-
Save kdmsnr/fd70c15fee792a38e8a28db7b8d4bc33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "/"で検索窓にフォーカスする | |
(() => { | |
const onKeyDown = function(e) { | |
if (e.keyCode == 191) { // 191 == "/" | |
if (location.pathname == "/YOUR_PROJECT/" || location.pathname == "/YOUR_PROJECT/search/page") { | |
if (document.activeElement != $(".form-control")[0]) { | |
e.preventDefault(); | |
$(".form-control")[0].focus(); | |
} | |
} | |
} | |
} | |
document.addEventListener('keydown', onKeyDown); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment