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?
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!");
}