Reputation: 14029
My code works perfect if I want to perform an action when pressing the ctrl key...
$(document).keydown(function(e){
if(e.ctrlKey){
if($('.selected').parent().next().length == 0){
switchTabs($('.selected').parent().parent().find('a:first'));
return false;
}else{
switchTabs($('.selected').parent().next().children('a'));
return false;
}
}
});
However I only want this code to activate when I press only the right control button...
if(e.rightctrlkey)
doesn't work... if there is a correct method, what is it?
Upvotes: 0
Views: 659
Reputation: 324707
You won't be able to do this in general. You can do it in IE only:
// Assuming you have a key event stored in variable 'e':
if (e.ctrlLeft) {
alert("Left!");
} else if (e.ctrlRight) {
alert("Right!");
}
Upvotes: 1
Reputation: 10071
Make use of event.keyLocation
attribute, Left=0, Right=1. Look over here for details.
Also look over in this stackoverflow question.
Upvotes: 0