Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate an "ontype" event

I want to simulate the Google Search effect that even with the search box not focused, the user can start typing and the input box will capture all keyboard strokes.

I have looked for an ontype event, but haven't found anything. I know that the event object in callbacks for events like click has keyboard information, but I don't think this is what I'm after.

like image 778
Randomblue Avatar asked Jan 18 '23 11:01

Randomblue


1 Answers

This does the job:

 $(document).on('keydown', function() {
     $('input').focus();
 });
like image 183
Randomblue Avatar answered Jan 28 '23 18:01

Randomblue