Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Auto focus on a text box after a key press

 
kul karni
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guyz,

I am looking for a technique that allows a textbox to be focussed automatically once a key is pressed on the keyboard.
More precisely, if I press a key on the keyboard, that character should appear automatically in that textbox with the cursor blinking.

For example, the main textbox of the Google Search Page, where the textbox starts capturing any key pressed.

Thank you.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google has focus in the textbox when the page loads.

Eric
 
kul karni
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Eric. I agree with you on this.

But try to click on an empty space on the google page so that the textbox loses focus,
then type some characters and you will find those characters in that textbox even after removing the focus.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Listen for key presses



If it is in the range you want, focus the textbox document.getElementById("yourTextBox").focus();, just check to make sure

Eric
 
kul karni
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Eric, I have no idea how to use this code. Please help me on this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic