css

   <style>
      /* 设置提示文本元素的样式 */
      #search-input-tooltip {
        display: none;
        position: absolute;
        background-color: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 5px;
        border-radius: 3px;
        font-size: 14px;
        z-index: 999;
        white-space: pre-line; /* 新增换行样式 */
      }
    </style>
    

HTML

<input type="text" id="search-input">


<!-- 提示文本元素 -->
<div id="search-input-tooltip">
  Alt+B使用百度搜索,
  Alt+Y使用必应搜索,
  Alt+i使用bilibili搜索
</div>

示例

<script>
  var searchInput = document.getElementById("search-input");
  var searchInputTooltip = document.getElementById("search-input-tooltip");

  // 鼠标悬停事件处理程序
  searchInput.addEventListener("mouseover", function() {
    // 显示提示文本
    searchInputTooltip.style.display = "block";
  });

  // 鼠标移出事件处理程序
  searchInput.addEventListener("mouseout", function() {
    // 隐藏提示文本
    searchInputTooltip.style.display = "none";
  });

  // 键盘事件处理程序
  document.addEventListener("keydown", function(event) {
    if (event.altKey) {
      var searchText = searchInput.value.trim();

      switch (event.keyCode) {
        case 66: // B 键
          window.location.href = "https://www.baidu.com/s?wd=" + encodeURIComponent(searchText);
          break;
        case 89: // Y 键
          window.location.href = "https://www.bing.com/search?q=" + encodeURIComponent(searchText);
          break;
        case 73: // I 键
          window.location.href = "https://search.bilibili.com/all?keyword=" + encodeURIComponent(searchText);
          break;
      }
    }
  });

  // 根据鼠标位置更新提示文本元素的位置
  document.addEventListener("mousemove", function(event) {
    searchInputTooltip.style.left = (event.pageX + 10) + "px";
    searchInputTooltip.style.top = (event.pageY + 10) + "px";
  });
</script>

简化搜索

var searchInput = document.getElementById("search-input");
var searchInputTooltip = document.getElementById("search-input-tooltip");

// 定义搜索引擎对象
var searchEngines = {
  baidu: "https://www.baidu.com/s?wd=",
  bing: "https://www.bing.com/search?q=",
  bilibili: "https://search.bilibili.com/all?keyword="
};

// 鼠标悬停事件处理程序
searchInput.addEventListener("mouseover", function() {
  // 显示提示文本
  searchInputTooltip.style.display = "block";
});

// 鼠标移出事件处理程序
searchInput.addEventListener("mouseout", function() {
  // 隐藏提示文本
  searchInputTooltip.style.display = "none";
});

// 键盘事件处理程序
document.addEventListener("keydown", function(event) {
  if (event.altKey) {
    var searchText = searchInput.value.trim();

    switch (event.keyCode) {
      case 66: // B 键
        openSearchEngine(searchEngines.baidu, searchText);
        break;
      case 89: // Y 键
        openSearchEngine(searchEngines.bing, searchText);
        break;
      case 73: // I 键
        openSearchEngine(searchEngines.bilibili, searchText);
        break;
    }
  }
});

// 根据鼠标位置更新提示文本元素的位置
document.addEventListener("mousemove", function(event) {
  searchInputTooltip.style.left = (event.pageX + 10) + "px";
  searchInputTooltip.style.top = (event.pageY + 10) + "px";
});

// 打开指定搜索引擎的搜索结果页面
function openSearchEngine(searchEngine, searchText) {
  window.location.href = searchEngine + encodeURIComponent(searchText);
}

更多

      var searchInputTooltip = document.getElementById("tooltip");
    
      var searchEngines = {
        baidu: "https://www.baidu.com/s?wd=",
        bing: "https://www.bing.com/search?q=",
        so360: "https://www.so.com/s?q=",
        sogou: "https://www.sogou.com/web?query=",
        quark: "https://quark.sm.cn/s?q=",
        neteaseMusic: "https://music.163.com/#/search/m/?s=",
        kugouMusic: "https://www.kugou.com/yy/html/search.html#searchType=song&searchKeyWord=",
        bilibili: "https://search.bilibili.com/all?keyword=",
        tencentVideo: "https://v.qq.com/x/search/?q=",
        iqiyi: "https://so.iqiyi.com/so/q_",
        mangguoTV: "https://so.mgtv.com/so?k=",
        baiduTranslate: "https://fanyi.baidu.com/#auto/zh/",
        zhihu: "https://www.zhihu.com/search?type=content&q=",
        huaban: "https://huaban.com/search/?q=",
        weibo: "https://s.weibo.com/weibo/"
      };
      
      searchInput.addEventListener("mouseover", function() {
        searchInputTooltip.style.display = "block";
      });
      
      searchInput.addEventListener("mouseout", function() {
        searchInputTooltip.style.display = "none";
      });
      
     document.addEventListener("keydown", function(event) {
  if (event.altKey && searchInput.value.trim() !== "") {
    var searchText = searchInput.value.trim();

    switch (event.keyCode) {
      case 66: // B 键
        openSearchEngine(searchEngines.baidu, searchText);
        break;
      case 89: // Y 键 
        openSearchEngine(searchEngines.bing, searchText);
        break;
      case 76: // L 键
        openSearchEngine(searchEngines.so360, searchText);
        break;    
      case 87: // W 键
        openSearchEngine(searchEngines.neteaseMusic, searchText);
        break;
      case 79: // O 键
        openSearchEngine(searchEngines.sogou, searchText);
        break;
      case 75: // K 键
        openSearchEngine(searchEngines.quark, searchText);
        break;
      case 71: // G 键
        openSearchEngine(searchEngines.kugouMusic, searchText);
        break;
      case 73: // I 键
        openSearchEngine(searchEngines.bilibili, searchText);
        break;
      case 84: // T 键
        openSearchEngine(searchEngines.tencentVideo, searchText);
        break;
      case 65: // A 键
        openSearchEngine(searchEngines.iqiyi, searchText);
        break;
      case 77: // M 键
        openSearchEngine(searchEngines.mangguoTV, searchText);
        break;
      case 70: // F 键
        openSearchEngine(searchEngines.baiduTranslate, searchText);
        break;
      case 90: // Z 键
        openSearchEngine(searchEngines.zhihu, searchText);
        break;
      case 72: // H 键
        openSearchEngine(searchEngines.huaban, searchText);
        break;
      case 86: // V 键
        openSearchEngine(searchEngines.weibo, searchText);
        break;
    }
  }
});

      
      document.addEventListener("mousemove", function(event) {
        searchInputTooltip.style.left = (event.pageX + 10) + "px";
        searchInputTooltip.style.top = (event.pageY + 10) + "px";
      });
      
      function openSearchEngine(searchEngine, searchText) {
        var url = searchEngine + encodeURIComponent(searchText);
        window.open(url, "_blank");
      }

html

Alt+B → 百度搜索 Alt+Y → 必应搜索 Alt+L → 360搜索 Alt+O → 搜狗搜索 Alt+K → 夸克搜索 Alt+W → 网易云搜索 Alt+G → 酷狗音乐搜索 Alt+i → bilibili搜索 Alt+T → 腾讯视频搜索 Alt+A → 爱奇艺搜索 Alt+M → 芒果TV搜索 Alt+F → 百度翻译 Alt+Z → 知乎搜索 Alt+H → 花瓣网搜索 Alt+V → 微博搜索