Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

whitelist specific keys to prevent re-rendering search results #56

Merged
merged 13 commits into from
Jan 27, 2016
Merged

Conversation

egladman
Copy link
Contributor

This addresses issue #55.

This whitelists the following keys:

  • up/down/left/right arrow keys
  • modifier key
  • shift key
  • enter key
  • caps lock key

event.which is technically deprecated, however it still is the 'go-to' means of detecting keyevents until KeyboardEvent.code gains support. Even jQuery still uses event.which.

If your curious how these changes effect the scripts behavior, checkout this site where I'm using this patched version.

Thanks for creating and maintaining this project

if( eval(keyCodes) ){
emptyResultsContainer()
if( e.target.value.length > 0 ){
render( repository.search(e.target.value) )

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon.

@christian-fei
Copy link
Owner

This is really great, thank you so much!
Will review the code as soon as I can

@egladman
Copy link
Contributor Author

Any updates?

@christian-fei
Copy link
Owner

Hello!
yeah could you convert the eval thing in a simple check whether the key isn't contained in the whitelist array?

like:

if( whitelist.indexOf(e.which) === -1 )

@egladman
Copy link
Contributor Author

Nice suggestion. I wish I thought of that myself.

christian-fei added a commit that referenced this pull request Jan 27, 2016
whitelist specific keys to prevent re-rendering search results
@christian-fei christian-fei merged commit d168211 into christian-fei:master Jan 27, 2016
@christian-fei
Copy link
Owner

thank you very much! you rock 👍

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

Successfully merging this pull request may close these issues.

None yet

3 participants