javascript - Catch keypress document wide and start typing in search box -


I want to capture all the key presses on my webpage so that when you start typing text, the search box (input)

jquery Can be:

  var $ search = $ ("#search"); $ (Document) .on ("keydown", function (e) {if (! $ Search.is (": focus")) if (e.he! = 9 & amp; e.which! = 13) $ search Focus ();});   

If the focus has already been set, then the .focus () function will not be called to set the focus on the input field. If the user pressed the tab or enter key, then the input field will not be selected!

Accessibility

If someone tries to use your mouse without a mouse (just with the keyboard), then navigate anywhere will not be able to. You may have to consider using additional techniques like HTML.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -