Click here to Skip to main content
15,885,842 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to create shortcut key in my own web application using asp.net? with example
Posted
Updated 2-Jun-15 1:46am
v2

JavaScript
$(/*selector*/).keypress(function(e) {
    var charPressed == e.which; //char code 
});
 
Share this answer
 
Hi,
Here is the small example of creating shortcut key :-



XML
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default7.aspx.cs"
 Inherits="Default7" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
   <title>Untitled Page</title>
  <script type="text/javascript">
  document.attachEvent('onkeyup', KeysShortcut);


// Now we need to implement the KeysShortcut
function KeysShortcut ()

{

    if (event.keyCode == 49)

    {
      document.getElementById('<%= button1.ClientID %>').click();

    }

}
  </script>
</head>
<body>
   <form id="form1" runat="server">
   <div>
   <asp:ScriptManager ID="a" runat="server"></asp:ScriptManager>
   </div>
  <div id="target" style="background-color: gray">This is a simple div</div>
    <asp:Button ID="button1" runat="server" />
   </form>
</body>


</html>



thanks
 
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