shortcuts for wordpress code example

Example: wordpress F keys keyboard to navigation

function my_custom_js() { ?>

    <script type="text/javascript">
        document.onkeydown = function (e) {
            var e = e || event, 
            keycode = e.which || e.keyCode; 
            if (keycode == 37 || keycode == 33)
                location = "<?php echo get_permalink(get_previous_post()); ?>";
            if (keycode == 39 || keycode == 34)
                location = "<?php echo get_permalink(get_next_post()); ?>";
        }
    </script>

<?php }
add_action('wp_footer', 'my_custom_js');

Tags:

Php Example