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

Don't create a new event handler every time a handler is registered for a key #11

Open
ruidfigueiredo opened this issue Mar 11, 2016 · 0 comments

Comments

@ruidfigueiredo
Copy link
Owner

This statement:

$(document)
.onLeftArrowKeyDown(previousPage)
.onRightArrowKeyDown(nextPage);

Will create two event handlers for keydown on document.

This could be improved by creating just one event handler for keydown, and eveytime a new key is registered, jQuery's data facilities could be used to store the information about which keys should be handled.

This would also facilitate de-registering an event handler for a specific key (just remove the data information about that key)

@ruidfigueiredo ruidfigueiredo changed the title A new event handler is created every time a handler is registered for a key Don't create a new event handler is created every time a handler is registered for a key Mar 11, 2016
@ruidfigueiredo ruidfigueiredo changed the title Don't create a new event handler is created every time a handler is registered for a key Don't create a new event handler every time a handler is registered for a key Mar 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant