Solved

jquery hotkeys

Posted on 2008-10-21
4
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to show popup no matter what a user clicks on navigation wise 10 64
Jquery Calculation 3 43
Ajax success not firing alert 6 45
Javascript function 3 23
This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

710 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