Greasy Fork is available in English.

百度搜索框快速定位

双击Shift即可快速定位百度搜索页面中的搜索框,Escape可使其失焦

// ==UserScript==
// @name         百度搜索框快速定位
// @namespace    http://tampermonkey.net/
// @version      2.1
// @icon         https://www.baidu.com/favicon.ico
// @description  双击Shift即可快速定位百度搜索页面中的搜索框,Escape可使其失焦
// @author       Fred
// @match        https://www.baidu.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const inter = 200;
    const typebox = document.querySelector('#kw');

    let last = new Date().getTime();

    document.documentElement.addEventListener('keydown', e => {
        if (e.keyCode === 16) {
            let current = new Date().getTime();
            if (current - last > inter) {
                last = current;
            } else {
                typebox.click();
                typebox.select();
            }
        }
    });

    typebox.addEventListener('keydown', e => {
        if (e.keyCode === 27) {
            typebox.blur();
        }
    });
})();