$(document.body).on('keydown', function(e) {
    switch (e.which) {
        // key code for left arrow
        case 37:
            console.log('left arrow key pressed!');
            break;
        
        // key code for right arrow
        case 39:
            console.log('right arrow key pressed!');
            break;
    }
});