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

feat: Add keyboard shortcut to package search and symbol search #77

Merged
merged 6 commits into from
Feb 29, 2024

Conversation

bartlomieju
Copy link
Contributor

@bartlomieju bartlomieju commented Feb 29, 2024

Package search shortcut: "Cmd + K" on Mac, "Ctrl + K" on Windows and Linux

Screenshot 2024-02-29 at 20 31 15

Symbol search shortcut: "Cmd + /" on Mac, "Ctrl + /" on Windows and Linux.

Screenshot 2024-02-29 at 20 59 39

Closes #30

@bartlomieju bartlomieju changed the title feat: Add keyboard shortcut to package search feat: Add keyboard shortcut to package search and symbol search Feb 29, 2024
@bartlomieju
Copy link
Contributor Author

@josh-collinsworth I also added keyboard shortcut for symbol search on package page (S). Please take another look.

frontend/islands/PackageSearch.tsx Outdated Show resolved Hide resolved
@@ -104,6 +104,20 @@ export function LocalSymbolSearch(
return () => document.removeEventListener("click", outsideClick);
}, []);

useEffect(() => {
const keyboardHandler = (e: KeyboardEvent) => {
if (e.key === "S") {
Copy link
Contributor

@josh-collinsworth josh-collinsworth Feb 29, 2024

Choose a reason for hiding this comment

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

Sorry, I didn't see this before but I don't think it's probably a good idea. There's lots of reasons a user might type S on a page. (Not least of which, in the package search in the header; if a user tries to type a capital S anywhere on the page, they'll be jumped to the search box.)

I think maybe we should just leave this one alone for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good catch. Changed the shortcut to Cmd + / and Ctrl + /. Let me know if that's better

@bartlomieju bartlomieju added this pull request to the merge queue Feb 29, 2024
Merged via the queue into main with commit ba0f218 Feb 29, 2024
5 checks passed
@bartlomieju bartlomieju deleted the add_keyboard_shortcut_to_global_search branch February 29, 2024 20:17
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.

Add keyboard shortcut to select package search
2 participants