Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Google detects input in search box to display instant results?

How is Google detecting user input? I looked around and the text field does not have the onkeyup or onchange events.

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

like image 362
AlexBrand Avatar asked Feb 26 '23 16:02

AlexBrand


2 Answers

it does have keyup and keydown listeners, but they are assigned at runtime, via addEventListener("keyup", ...). Use your browser's DOM inspector to select the input element, and then drill into the event listeners currently assigned (in webkit's inspector, that's under "Event Listeners" at the bottom of the right-hand pane) -- you'll see keyup, keydown, and several others.

like image 194
Lee Avatar answered Feb 28 '23 09:02

Lee


It does have event listeners. Using the inspect element on chrome you can clearly see the listeners - highlighted in the screen shot below.

alt text

like image 31
Josh Avatar answered Feb 28 '23 09:02

Josh