Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call function when textbox is active

Status
Not open for further replies.

LebronJames

Programmer
Apr 5, 2003
93
I have a text box and I want the function to run only if the text box is active. (user has clicked or tab over to the TxtBox1) and the user presses F9 on their keyboard



document.onkeyup = handleKeyUp;

function handleKeyUp(e)
{
if(!e)
var e = window.event;

key = e.keyCode;
Frm.txtBox1.value = key;

if (key == 120)
{
alert("You pressed F9 key");
}

}
 
Instead of document.onkeyup = handleKeyUp; use

<input type="text" onkeyup="handleKeyUp()">

Adam
while(ignorance){perpetuate(violence,fear,hatred);life=life-1};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top