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

Allow ⌘F to search on page #8

Closed
Samasaur1 opened this issue Jan 14, 2021 · 1 comment · Fixed by #13
Closed

Allow ⌘F to search on page #8

Samasaur1 opened this issue Jan 14, 2021 · 1 comment · Fixed by #13

Comments

@Samasaur1
Copy link
Owner

Currently, we intercept ⌘F (and ^F on non-macOS) and redirect it to our search field. However, this means that people cannot search on the page. Maybe we should do what GitHub does and use / as the search shortcut. If we replace this:

<script type="text/javascript">
window.addEventListener("keydown", function(e){
if ((e.ctrlKey || e.metaKey) && e.keyCode === 70) { //⌘F or ⌃F (find on page)
e.preventDefault();
document.getElementById("search-field").focus();
}
});
</script>

with the following JavaScript:

window.addEventListener("keydown", function(e) { 
  if (e.keyCode === 191) {
    e.preventDefault(); 
    document.getElementById("search-field").focus(); 
  }
});

then / selects the search field, but doesn't type into it. We'd need to only sometimes use e.preventDefault(), depending on whether the search field was selected, but that should be doable.

We should also have the little hint that GitHub has in its search bar that shows that / selects it.

@Samasaur1
Copy link
Owner Author

Or maybe use ⇧⌘F?

@ghost ghost added the Pending PR The resolution to this issue is in a PR label Oct 2, 2021
@ghost ghost removed the Pending PR The resolution to this issue is in a PR label Oct 5, 2021
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 a pull request may close this issue.

1 participant