Scroll to next div using arrow keys
<p>I want my Left/Right arrow to go to the Next/Previous <code>.embedded_post</code> div. The problem is that it only works once and I can only scroll between the first and second div. I thought it was the offset of -100 but removing the offset did not do the trick. I'm thinking that after I animate to the next div, the jQuery selector has not moved anywhere so I'm stuck.</p>

<pre><code>jQuery(document).keydown(function(e){
    switch(e.which) {
        case 37: // left
            jQuery('html, body').animate({scrollTop:jQuery('.embedded_post').prev().offset().top - 100}, 500);          
            return;
        break;

        case 38: // up
        break;

        case 39: // right
            var next_embed = jQuery('.embedded_post').next();
            jQuery('html, body').animate({scrollTop:next_embed.offset().top - 100}, 500);
            return;
        break;

        case 40: //down
        break;

        default: return; // exit this handler for other keys
    }
    e.preventDefault();
});
</code></pre>
