var $menu = $('.menu'),
$items = $menu.find('li'),
num = $items.length,
current = -1;
$(document).on('keyup', function (e) {
var key = e.which;
switch (key) {
case 38:
current--;
if (current < 0) {
current = num - 1;
}
break;
case 40:
current++;
if (current > num - 1) {
current = 0;
}
break;
};
$items.eq(current).addClass('active').siblings().removeClass('active');
});