Link to home
Start Free TrialLog in
Avatar of jpking72
jpking72

asked on

jquery hotkeys

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

Avatar of MacAnthony
MacAnthony
Flag of United States of America image

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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of sh0e
sh0e

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jpking72
jpking72

ASKER

correct shoe...for another 250...what do i tell the handler to do to make it output a "\t" (tab) character?
"\t"
function response() {
	$('[name="input1"]').val($('[name="input1"]').val() + '\t');
}

Open in new window