| Author |
Auto focus on a text box after a key press
|
kul karni
Greenhorn
Joined: Nov 19, 2011
Posts: 12
|
|
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
Joined: Nov 08, 2001
Posts: 15357
|
|
Google has focus in the textbox when the page loads.
Eric
|
 |
kul karni
Greenhorn
Joined: Nov 19, 2011
Posts: 12
|
|
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
Joined: Nov 08, 2001
Posts: 15357
|
|
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
Joined: Nov 19, 2011
Posts: 12
|
|
|
Sorry Eric, I have no idea how to use this code. Please help me on this.
|
 |
 |
|
|
subject: Auto focus on a text box after a key press
|
|
|