Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jquery hotkeys

Posted on 2008-10-21
4
Medium Priority
?
382 Views
Last Modified: 2008-10-22
i'm trying to set a key (alt+a) to equal a tab ("\t") with the code below.  but when i run it the handler reacts to any key not just alt+a
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="scripts/jquery.hotkeys-0.7.8.js"></script>
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript">
  $(document).bind('keydown','alt+a',response);
function response() {
alert("tab");
}
 </script>
</head>
<body>
Hi
<input type="text" name="input1" />
</body>
</html>

Open in new window

0
Comment
Question by:jpking72
  • 2
4 Comments
 
LVL 11

Expert Comment

by:MacAnthony
ID: 22770600
Try this
$(document).keypress( function (e) {
    if (e.which == 97 )
        alert('works');
});

Open in new window

0
 
LVL 16

Accepted Solution

by:
sh0e earned 2000 total points
ID: 22770648
<script type="text/javascript" src="scripts/jquery.hotkeys-0.7.8.js"></script>
<script type="text/javascript" src="scripts/jquery.js"></script>
Wrong order of inclusion, should be:
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/jquery.hotkeys-0.7.8.js"></script>
0
 

Author Comment

by:jpking72
ID: 22770748
correct shoe...for another 250...what do i tell the handler to do to make it output a "\t" (tab) character?
0
 
LVL 16

Expert Comment

by:sh0e
ID: 22770902
"\t"
function response() {
	$('[name="input1"]').val($('[name="input1"]').val() + '\t');
}

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question