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

#134, Focus search field by pressing s or / #135

Merged
merged 2 commits into from
Jan 19, 2020

Conversation

skoskav
Copy link

@skoskav skoskav commented Jan 19, 2020

Resolves #134 by emulating GitHub's behavior.

Tested in Chrome, FF and IE 11.


function isHotkey(character) {
const dataHotkeys = input.getAttribute('data-hotkeys') || '';
const hotkeys = dataHotkeys.split(' ');
Copy link
Owner

Choose a reason for hiding this comment

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

🤔Maybe can be shortened to:
return dataHotkeys.indexOf(character) >= 0

Considering any char in dataHotkeys as possible trigger.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed, it looks better.

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure about making any key trigger the search field though, as that might have to be reverted in case another shortcut was ever added.

@alex-shpak
Copy link
Owner

Looks good 👍

@alex-shpak alex-shpak merged commit 2acd6ab into alex-shpak:master Jan 19, 2020
tyler71 pushed a commit to tyler71/hugo-book that referenced this pull request Jan 22, 2020
* alex-shpak#134, Focus search field by pressing s or /
* alex-shpak#134, Refactoring away an array loop using indexOf
tyler71 pushed a commit to tyler71/hugo-book that referenced this pull request Jan 22, 2020
* alex-shpak#134, Focus search field by pressing s or /
* alex-shpak#134, Refactoring away an array loop using indexOf
tyler71 pushed a commit to tyler71/hugo-book that referenced this pull request Jan 22, 2020
* alex-shpak#134, Focus search field by pressing s or /
* alex-shpak#134, Refactoring away an array loop using indexOf
tyler71 pushed a commit to tyler71/hugo-book that referenced this pull request Jan 22, 2020
* alex-shpak#134, Focus search field by pressing s or /
* alex-shpak#134, Refactoring away an array loop using indexOf
tyler71 pushed a commit to tyler71/hugo-book that referenced this pull request Jan 22, 2020
* alex-shpak#134, Focus search field by pressing s or /
* alex-shpak#134, Refactoring away an array loop using indexOf
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

Successfully merging this pull request may close these issues.

Keyboard shortcut for focusing the search field
2 participants