Skip to content

Conversation

@sp3cia1
Copy link

@sp3cia1 sp3cia1 commented Feb 2, 2026

Summary of Changes

This PR addresses Issue #8 by redesigning the ExtraKeys component to match Termux's aesthetic. While implementing the UI changes, I discovered several UX bugs that made the mobile experience frustrating, so I took the initiative and fixed those as well.

UI Changes

  • Redesigned ExtraKeys with pill-shaped buttons, shadows, and touch-responsive active states
  • Increased touch target size for better mobile usability
  • Added visual feedback with scale animation on press

UX Bug Fixes (Autonomy)

Bug Fix
Tapping TouchArea opened keyboard Removed auto-focus behavior
Tapping ControlBar buttons (L-Click, R-Click, etc.) opened keyboard Added e.preventDefault() in handlers
Tapping ExtraKeys opened keyboard Added preventDefault + stopPropagation on pointer events
Swiping ExtraKeys triggered key presses Implemented scroll vs tap detection using movement threshold
Keyboard button only opened keyboard (couldn't close it) Fixed toggle logic to handle both open and close states reliably
Back button dismissal broke keyboard toggle Synced keyboard state via visualViewport resize events

Justification

Per contribution guidelines on Autonomy & Decision-Making, changes that improve usability may be made when the specification is silent. The original issue focused on UI, but the keyboard bugs made the app nearly unusable on mobile. Fixing them was necessary to deliver a quality implementation.

Key technical decisions:

  • visualViewport API: Used to reliably detect keyboard visibility. Comparing against stored originalHeight since both visualViewport.height and window.innerHeight shrink together when keyboard opens.
  • Pointer events over touch events: Better cross-platform support and allows preventDefault to block focus changes.
  • Movement threshold (10px): Differentiates scroll gestures from taps on ExtraKeys.

Platform-Specific Behavior

Platform Behavior
Android Tested. Keyboard toggle works with both button and back gesture. ExtraKeys don't interfere with keyboard.
iOS Should work (same APIs), but not personally tested.
Desktop (Linux & Windows) Unaffected. Mouse interactions work as expected.

Videos

Before (Old UI + Bugs):

rein_before_bug_fixes.mp4

After (New UI + Fixes):

rein_after_bug_fixes.mp4

Fixes #8
and other massive ux improvements.

Summary by CodeRabbit

Release Notes

  • New Features

    • Trackpad keys now feature gesture detection to prevent accidental key presses from subtle movements.
    • Improved mobile keyboard handling with automatic viewport-based detection and management.
    • Added visual feedback for active trackpad key states.
  • Bug Fixes

    • Enhanced keyboard toggle mechanism for more reliable behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

These changes implement pointer gesture handling with movement threshold detection in the ExtraKeys component and refactor keyboard state management in the trackpad route to use viewport-based synchronization instead of focus-based triggers.

Changes

Cohort / File(s) Summary
Pointer Gesture Workflow
src/components/Trackpad/ExtraKeys.tsx
Implemented full pointer event handling with movement threshold (10px); added activeKey state and ref-based position tracking; key presses are canceled if pointer moves beyond threshold; added visual styling for pressed states; removed onInputFocus prop from component interface.
Keyboard State Management
src/routes/trackpad.tsx
Refactored keyboard visibility tracking using viewport resize detection; introduced keyboardOpenRef and useEffect hook to toggle keyboard based on viewport height changes; replaced focus-based keyboard triggering with toggleKeyboard callback; removed autofocus behavior and container click handlers; simplified ExtraKeys usage by removing onInputFocus prop.

Sequence Diagram(s)

sequenceDiagram
    participant User as User/Pointer
    participant ExtraKeys as ExtraKeys Component
    participant State as Internal State
    participant Parent as Parent Component

    User->>ExtraKeys: Pointer Down
    ExtraKeys->>State: Record start position, set activeKey
    ExtraKeys->>ExtraKeys: preventDefault & stopPropagation

    User->>ExtraKeys: Pointer Move
    ExtraKeys->>ExtraKeys: Calculate dx/dy from start
    alt Movement > MOVE_THRESHOLD
        ExtraKeys->>State: Mark as moved, clear activeKey
    end

    User->>ExtraKeys: Pointer Up
    ExtraKeys->>State: Check if moved and key active
    alt Not moved AND key still active
        ExtraKeys->>Parent: sendKey(lowercase key)
    end
    ExtraKeys->>State: Reset all tracking state
Loading
sequenceDiagram
    participant Window as Window Viewport
    participant Effect as useEffect Hook
    participant Ref as keyboardOpenRef
    participant Input as Hidden Input

    Window->>Effect: Trigger on resize
    Effect->>Effect: Check viewport height < 85%
    alt Viewport reduced (keyboard visible)
        Effect->>Ref: Set keyboardOpenRef.current = true
    else Viewport normal
        Effect->>Input: blur() hidden input
        Effect->>Ref: Reset keyboardOpenRef
    end

    Note over Window,Input: toggleKeyboard callback<br/>(on user action)
    Input->>Input: focus() or blur() based on keyboardOpenRef
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit taps with grace and care,
Detecting every pointer's lair,
Ten pixels' slide to cancel keys,
While viewports dance, the keyboard flees!
No focus tricks, just viewport sight—
A gesture dance done smooth and right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: ExtraKeys UI redesign and mobile keyboard UX fixes, which are the primary focus of this PR.
Linked Issues check ✅ Passed The PR implements the requirements from Issue #8: redesigning ExtraKeys UI with Termux-like aesthetics and demonstrating the changes with videos as requested.
Out of Scope Changes check ✅ Passed All code changes are directly related to the ExtraKeys UI redesign and mobile keyboard UX improvements outlined in Issue #8; no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@aniket866 aniket866 left a comment

Choose a reason for hiding this comment

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

Overall changes improve stability, touch/keyboard handling, and user experience, especially on mobile devices.

Everything is handled correctly

Copy link
Contributor

Choose a reason for hiding this comment

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

Better touch handling with pointer events and movement threshold improves accuracy and UX.

Copy link
Contributor

Choose a reason for hiding this comment

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

Better keyboard state handling improves mobile behavior and prevents bugs.

@aniket866
Copy link
Contributor

hi @sp3cia1 I have reviewed your PR , changes are good , nice work on UX specially for mobile , improving button UX,
but , your PR has some merge conflicts , Please resolve them first

@imxade imxade closed this Feb 11, 2026
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.

ExtraKeys UI

3 participants