开发者

Google's predictive text as you type code example - w/o auto suggest dropdown menu

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开发者_Go百科 - without auto suggest dropdown menu.


i found one similar script here which suggest words like google when user type search query

https://sourceforge.net/projects/searchpuppy/files/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜