How does Google detect input in the search box to display instant results?

How does Google detect user input? I looked around and there are no onkeyup or onchange events in the text box.

Is there any other way to detect user input in a text box?

thanks

+4
source share
4 answers

it has keyup and keydown , but they are assigned at runtime via addEventListener("keyup", ...) . Use your DOM inspector in the browser to select the input element, and then expand it into the event listeners that are currently assigned (in the web kit inspector, which is located under the "Event listeners" at the bottom of the right panel) - you will see the keyboard, keydown, and several others.

+6
source

He has event listeners. Using the check element on chrome, you can clearly see the listeners - highlighted in the screenshot below.

alt text

+2
source

I would say the onblur onkeyup / down event, which fires a custom event, waiting for a pause or space, then sends data, and then processes the return.

After playing with it for a while, here is what I came up with in jsfiddle:

http://jsfiddle.net/fauxtrot/Ejqyb/

0
source
0
source

All Articles