Skip to content

feat(keyboard): add keyboard shortcuts#10

Merged
brysonbw merged 14 commits intoCode-Cause-Collective:mainfrom
Dhruv-Rankoti:feature/keyboard-bindings
Nov 28, 2025
Merged

feat(keyboard): add keyboard shortcuts#10
brysonbw merged 14 commits intoCode-Cause-Collective:mainfrom
Dhruv-Rankoti:feature/keyboard-bindings

Conversation

@Dhruv-Rankoti
Copy link
Contributor

@Dhruv-Rankoti Dhruv-Rankoti commented Nov 22, 2025

This PR adds full keyboard shortcut support to improve usability and speed when interacting with the Timer.
Fixes #9

✅ Added Keyboard Shortcuts

Shortcut Action
SPACE Start / Pause timer
ALT + P Switch to Pomodoro mode
ALT + S Switch to Short Break
ALT + L Switch to Long Break
ALT + R Reset timer

These shortcuts work globally while the <home> component is loaded.


🛠️ Implementation Details

New logic added

  • connectedCallback() now registers a keydown listener.
  • disconnectedCallback() removes the listener to avoid leaks.
  • New private method: #handleShortcut(event)
  • New helper method: #triggerTimerAction(action)
    This prevents duplicate logic and safely triggers timer events programmatically.
  • Mode-switching shortcuts simulate a real button click to preserve existing behavior.

Updated behavior

  • SPACE toggles between Start ↔ Pause depending on timer state.
  • ALT combos directly select the corresponding mode or reset.

📁 Main changes made to src/pages/home.js

Added:

window.addEventListener('keydown', this.#handleShortcut);

#handleShortcut = (event) => {
  // ALT combos for modes
  // SPACE for start/pause
};

#triggerTimerAction(action) { ... }

Removed:

No breaking changes, existing functionality remains untouched.

✔️ Result

Users can now control the Timer far more efficiently without relying on the UI buttons.
This closes Issue #9 and adds a significant accessibility improvement.

@brysonbw brysonbw changed the title ✨ Add Keyboard Shortcuts (Fixes #9) feat(keyboard): Add keyboard shortcuts Nov 24, 2025
@brysonbw brysonbw changed the title feat(keyboard): Add keyboard shortcuts feat(keyboard): add keyboard shortcuts Nov 24, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 28, 2025

🦋 Changeset detected

Latest commit: 849b7e4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
studytimer.io Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brysonbw brysonbw merged commit fc3ab91 into Code-Cause-Collective:main Nov 28, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add keyboard short cuts

2 participants