Solved

jquery hotkeys

Posted on 2008-10-21
4
372 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…
Suggested Courses

632 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