Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every one,

On F2 press in textbox keypress event i need to show a popup window. Even though i use keycode of F2 as 113, its not working. I write this ketpress event in javascript as

if(window.event && window.event.keyCode == 113)
{
popup.show();
}

but this is not working. can any one sujjest the reason or provide the suitable code for F2 press
Posted

You can use jQuery to trap the keypress events.

jQuery .keypress()[^] - View the demo provided on this page.
 
Share this answer
 
Hi Swathi,

Try this

XML
<script language="javascript">
document.onkeyup = KeyCheck;

function KeyCheck(e)
{
   var KeyID = (window.event) ? event.keyCode : e.keyCode;
   if(KeyID == 113)
   {
      alert("hi");
   }
}
</script>
 
Share this answer
 
document.onkeydown = function Open(event){

if(window.event && window.event.keyCode == 113)
{
document.getElementById('ctl00_ContentPlaceHolder1_ImageButton5').click();
}
else if(event.which == 113)
{
document.getElementById('ctl00_ContentPlaceHolder1_ImageButton5').click();

}


}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900