How can I combine these if
statements to make this a little cleaner and be less repetitive?
$(document).keydown(function(e){
if (e.keyCode == 38) {
if($html.hasClass('client-loading') || canAnim === false) {
return false;
}
var $prevProj = $('.project-current').prev('.project');
$prevProj.click();
}
if (e.keyCode == 40) {
if($html.hasClass('client-loading') || canAnim === false) {
return false;
}
var $nextProj = $('.project-current').next('.project');
$nextProj.click();
}
// Prevent rapid clicking
if ( e.keyCode == 38 || e.keycode == 40 ) {
canAnim = false;
setTimeout(function(){
canAnim = true;
},2000);
}
});