键入代码示例时 Google 的预测文本 - 不带自动建议下拉菜单
谷歌的新预测文本通过以浅灰色字体显示下一个字符来预测“当您在框中键入”时的搜索。有谁知道有任何代码可以做到这一点吗?我知道典型的建议下拉菜单,但我正在寻找在搜索框中执行所有操作的示例代码 - 没有自动建议下拉菜单。
Google's new predictive text predicts the search "as you type" in the box by showing the next characters in light gray font. Does anyone know of any code that does this? I am aware of the typical suggest drop down menus but I am looking for example code that does everything in the search box - without auto suggest dropdown menu.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在这里发现了一个类似的脚本,当用户输入搜索查询
https://sourceforge.net/ 时,它会建议像 google 这样的词项目/searchpuppy/文件/
i found one similar script here which suggest words like google when user type search query
https://sourceforge.net/projects/searchpuppy/files/
我不确定是否存在,但构建一个的逻辑似乎很简单。
在我看来,预测始终是自动完成列表中的第一项。预测通过两个具有透明背景的文本输入来显示,一个文本输入位于另一个文本输入的下方。底部输入将包含预测(银色文本);顶部输入是用户键入的位置。
当用户键入时,自动完成功能会找到建议列表。采用第一个建议并用它填充预测输入。
将 onKeyPress 事件绑定到用户输入框并观察用户按下右箭头键。如果用户按下它,则用预测框的值填充用户输入框。
I'm not sure if there are any that exists, but the logic to build one seems simple enough.
It seems to me that the prediction is always the first item in the autocomplete list. The prediction is displayed by having two text inputs with transparent backgrounds, one layered underneath the other. The bottom input will contain the prediction (silver text); The top input is where the user types.
As the user types, the autocomplete finds a list of suggestions. Take the first suggestion and populate the prediction input with it.
Bind an onKeyPress event to the user-input box and watch for the user to press the right arrow key. If user presses it, populate the user-input box with the value of the prediction box.