【村民blog更新】"/"快捷键搜索
当用键盘输入“/”时,会自动聚焦到搜索框:
var search = document.querySelector('input');
document.addEventListener('keyup', function(event) {
if (event.keyCode === 191) {
s.focus();
}
});
(村民blog的搜索框id=s,用focus聚焦的)
讨饭
![](https://blog.khboys.cn/uploadfiles/afdian-XXX%E6%9D%91%E6%B0%91.jpg)
![](https://blog.khboys.cn/uploadfiles/afdian-XXX%E6%9D%91%E6%B0%91.jpg)
爱发电
![](https://blog.khboys.cn/uploadfiles/afdian-XXX%E6%9D%91%E6%B0%91-qrcode.jpg)
爱发电二维码
我手机也能体验,我在输入/,自己给我弹到顶部去了,虽然没看到搜索框在哪里