jaukia / zoomooz

An easy-to-use jQuery plugin for making zooming web pages.
http://janne.aukia.com/zoomooz/
1.79k stars 275 forks source link

Use navegation from Keyboard #107

Open jcarol16 opened 9 years ago

jcarol16 commented 9 years ago

Hello, I need to navigate between areas via the keyboard. (key left and right arrows).

celiah commented 8 years ago

I've had success with this (note, this requires adding the html for the prev/next buttons, and the extra .prev and .next classes in that html):

        $(document).keydown(function(e) {

            var prev = $('.zoomButton.prev');
            var next = $('.zoomButton.next');

            switch(e.which) {
                case 37: // left
                    $('.zoomButton.prev').trigger('click');
                break;

                case 38: // up
                break;

                case 39: // right
                    $('.zoomButton.next').trigger('click');
                break;

                case 40: // down
                break;

                default: return; // exit this handler for other keys
            }
            e.preventDefault(); // prevent the default action (scroll / move caret)
        });