Skip to content

feat: add keyboard shortcut for theme toggle#405

Open
seffhunnn wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
seffhunnn:feat/theme-toggle-keyboard-shortcut
Open

feat: add keyboard shortcut for theme toggle#405
seffhunnn wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
seffhunnn:feat/theme-toggle-keyboard-shortcut

Conversation

@seffhunnn
Copy link
Copy Markdown
Contributor

Summary

Added a global keyboard shortcut for instantly toggling between light and dark themes directly from the dashboard. Also updated the shortcuts modal and added aria-live announcements for improved accessibility.

Closes #230

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup

Changes Made

  • Added global T keyboard shortcut for theme toggling
  • Prevented shortcut activation while typing in inputs/textareas/contenteditable elements
  • Reused existing theme toggle functionality
  • Added T — Toggle theme entry to the shortcuts modal
  • Added aria-live announcements for screen readers
  • Added proper keyboard event cleanup handling

How to Test

Steps for the reviewer to verify this works:

  1. Run the project locally using npm run dev
  2. Open the dashboard page
  3. Press T and verify the theme toggles instantly
  4. Press T multiple times and verify the theme switches correctly
  5. Focus an input or textarea and press T
  6. Verify the theme does not toggle while typing
  7. Press ? to open the shortcuts modal
  8. Verify T — Toggle theme appears in the shortcuts list
  9. Verify aria-live announcements update correctly after theme changes
  10. Open browser console and verify there are no warnings or errors
  11. Run npm run lint
  12. Run npm run type-check

Screenshots (if UI change)

N/A

Checklist

  • Linked issue in summary
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Self-reviewed the diff
  • Added/updated tests if applicable

@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

@seffhunnn is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

1. D shortcut still active but undocumented — the handler fires on both t and d, but ShortcutsModal only shows T. Either remove d from the handler, or show both keys in the modal.

2. aria-live announcement fires on click-toggle too — the useEffect watches theme and announces on every change, including button clicks. Screen reader users clicking the toggle button hear a redundant second announcement. Scope the announcement to keyboard events only (set a ref flag in the keydown handler, read + clear it in the effect).

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature labels May 20, 2026
@seffhunnn
Copy link
Copy Markdown
Contributor Author

Hii @Priyanshu-byte-coder i have addressed the review feedback by removing the undocumented D shortcut so only T toggles the theme now, and i also updated the aria live announcement logic so screen readers only get announcements when the theme is changed using the keyboard shortcut and not through mouse clicks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Add keyboard shortcut to toggle dark/light mode (press T)

2 participants