Click here to Skip to main content
14,695,325 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

Is there a possibility to add a keyboard shortcut to asp.net menu ?
Posted

1 solution

You can use this jQuery plugin. Very easy to use:
http://rikrikrik.com/jquery/shortkeys/[^]

You can add more watch-keys (like ALT, CTRL etc)
this.wackyKeys = { '.': 190, ',': 188, ';': 59,	'Space': 32	};


Add shortcuts. Trigger click on your menuitems. You will have to find the ID of the a-tag in your menu.

// implement shortcuts 
$(document).shortkeys({
  'Space+1' : function () { 
     $('#menuItem2').trigger('click'); 
  },
  'Space+2' : function () { 
     $('#menuItem2').trigger('click'); 
  }
});
   
Comments
Vinodh.B 4-Aug-12 15:33pm
   
I could not make it work . Can you pls suggest changes in following code.

<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery.shortkeys.js">
</script>
<script type="text/javascript">
$(document).shortkeys({
'Space+1': function () {
$('#Home').trigger('click');
},
'Space+2': function () {
$('#Sales').trigger('click');
}
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Menu ID="menu" runat="server">
<items>
<asp:MenuItem Text="Home">
<asp:MenuItem Text="Sales">


</div>
</form>
</body>
</html>

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