Solved

jquery hotkeys

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now