Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbinding all keydown functions. #36

Open
codesignist opened this issue Sep 25, 2017 · 0 comments
Open

Unbinding all keydown functions. #36

codesignist opened this issue Sep 25, 2017 · 0 comments

Comments

@codesignist
Copy link

In the close function, this code unbinds all keydown events:
$(document).off('keydown');

Need to describe a keyDown function:

keyDownEvent: function (e) {
    // Close lightbox with ESC
    if (e.keyCode === 27) {
        plugin.close();
    }
    // Go to next image pressing the right key
    if (e.keyCode === 39) {
        plugin.next();
    }
    // Go to previous image pressing the left key
    if (e.keyCode === 37) {
        plugin.previous();
    }
}

and need to add:
$(document).on('keydown', plugin.keyDownEvent);

and to remove only this function:
$(document).unbind('keydown', plugin.keyDownEvent);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant