Skip to content

Add Keyboard Shortcuts System #2365

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

george-hub331
Copy link
Contributor

@george-hub331 george-hub331 commented Apr 6, 2025

Fixes #2350

Summary

This PR adds a centralized keyboard shortcuts system using React Context, making it easier to manage and customize keyboard shortcuts throughout the application.

Changes

  • Added ShortcutsContext to manage global keyboard shortcuts
  • Created useShortcuts hook for easy shortcut registration
  • Converted ShortcutModal to TypeScript
  • Added support for key combinations (e.g. Shift + ?)
  • Improved modal layout using CSS Grid
  • Added proper TypeScript types and interfaces
  • Prevented shortcut execution in modal inputs
  • Added automatic grouping of shortcuts by category

Implementation Details

  • Used React Context for centralized state management
  • Added support for modifier keys (Shift, Ctrl, Alt, Meta)
  • Added proper cleanup of event listeners
  • Made shortcuts configurable per component
  • Maintained backwards compatibility with existing shortcuts

New improvements

  • Resolved bugs on shortcut hooks, prevent shortcuts from interfering with inputs / modals / other operations
  • Added new general shortcuts for showing tour help(shift + H), focusing on QmHash or CID input(on all screens)(/)
  • Added shortcuts on peers page
  • Rearraged shortcut sections

Short Demo

demo.mp4

george-hub331 and others added 8 commits April 6, 2025 20:49
- Added a new "General" shortcut label in the app localization.
- Refactored shortcut handling in the FilesGrid and FilesList components to use refs for focused file management.
- Improved keyboard shortcut handling by integrating the useShortcuts hook for better organization and functionality.
- Adjusted the order of shortcut groups in the shortcut modal for improved user experience.
@george-hub331 george-hub331 marked this pull request as ready for review April 13, 2025 19:52
@george-hub331 george-hub331 requested a review from a team as a code owner April 13, 2025 19:52
@george-hub331
Copy link
Contributor Author

Hi @SgtPooki, I’ve made an attempt at addressing the issue and would appreciate your review when you have a moment.

@SgtPooki
Copy link
Member

Hi @SgtPooki, I’ve made an attempt at addressing the issue and would appreciate your review when you have a moment.

It might take me a while to get to review this one thoroughly.

@george-hub331
Copy link
Contributor Author

No worries at all, I understand. Thanks for the heads-up, and I’ll be around if you need anything clarified when you get to it!

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.

feat: create shortcut component that can be used on any page
2 participants