Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to open the form on the f11 key press..can anybody please help me
Posted
Comments
ZurdoDev 12-Jul-12 8:12am    
Did you google how to capture keystrokes in JS?
[no name] 12-Jul-12 8:15am    
actually i did not done it before so i have no knowledge can you please help me
Sandeep Mewara 12-Jul-12 8:55am    
In ASP.NET web application, What do you mean by 'Open form'?

Further, why F11? It's a full screen shortcut for a web page.
[no name] 12-Jul-12 9:01am    
means when i run my application in this there exist master page inside master page .ascx means web user controls can be registered so when we want to open one by one registered web forms i have one web form which includes file upload control so i want this file upload control web form can be opened on the key press f11

1 solution

If you want to capture keystrokes (like F11) and perform actions based upon that information (like opening a form), this article has the explanation of how to do that and sample code to help you out:

http://support.microsoft.com/kb/320584[^]

However, you have tagged your question as ASP.NET. This won't work in the browser. To do that, you would need to look into Javascript or jQuery. Here is a possible solution:

http://stackoverflow.com/questions/424407/handling-key-press-events-f1-f12-using-javascript-and-jquery-cross-browser[^]

One of the things that the above Stack Overflow question points out is that listening to the function keys in the browser is a bad idea. They are reserved for browser tasks (for example, F11 is usually reserved for fullscreen mode in the browser). Also, different browsers will work differently in how they capture the keys (or don't capture the keys). It makes for a much more difficult capture and you need to be aware of that going in.
 
Share this answer
 
Comments
[no name] 12-Jul-12 9:20am    
no its not helpfull for me
Tim Corey 12-Jul-12 9:25am    
Why not? Based upon your clarification in the comments above, the second option is the way you need to go. You will need to do this code in Javascript, since ASP.NET C# code is server-side and won't "hear" the keypress event. Only client-side code will.
[no name] 12-Jul-12 9:28am    
i have heard but its not helpfull to me it gives me errors
Tim Corey 12-Jul-12 9:34am    
You are going to get a lot of those. What you are trying to do is barely on the edge of possible and it is overriding the functionality of the application you are running. I would recommend updating this question with the code you are trying (using the Improve question link above) along with what error you are getting and what browser you are testing it in.

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