Reputation: 3362
I have this code
I use jkey to simplify the usage on detecting which key is pressed.
Question
What i want is when any other except up arrow key is pressed set the value of count
to -1
and if up arrow key is pressed do it just like in the code.
Is there a way out by using the jKey plugin ? if not then how do i do it with normal jquery
Upvotes: 1
Views: 308
Reputation: 18786
This obviously doesn't get you exactly where you want to go but it should get you started.
HTML
<textarea id="myBigText"></textarea>
JS
$(document).ready(function() {
$("#myBigText").keydown(function(evt) {
evt = evt || window.event;
var charCode = evt.which || evt.keyCode;
if(charCode == 38) {
alert("This is the up arrow key");
} else {
alert("This is not the up arrow");
}
});
});
Upvotes: 1
Reputation: 9244
jKey doesn't work this way. You have to explicitly tell it what you want to look for. There's no "any key" option. You should fork it on github and add in this feature.
Upvotes: 0