Skip to content

fix: mobile keyboard input in playground terminal#2

Merged
akesling merged 2 commits intomainfrom
akesling/term
Mar 9, 2026
Merged

fix: mobile keyboard input in playground terminal#2
akesling merged 2 commits intomainfrom
akesling/term

Conversation

@akesling
Copy link
Copy Markdown
Contributor

@akesling akesling commented Mar 9, 2026

Summary

  • Replace onKey with onData as the sole xterm.js input handler — onKey relies on KeyboardEvent which mobile virtual keyboards don't fire, causing every keystroke to be silently dropped
  • Default to emacs mode on mobile (virtual keyboards lack an Escape key, making vi command mode a trap)
  • Add tap-to-focus so tapping the terminal opens the virtual keyboard on mobile

Net -212 lines — the onData approach matches terminal byte sequences in switch statements instead of juggling domEvent.code / domEvent.ctrlKey, which is both simpler and what xterm.js recommends.

Test plan

  • Desktop: verify typing, backspace, arrows, history (up/down), Ctrl+C, Escape→vi command mode all still work
  • Desktop: verify paste works
  • Desktop: verify emacs mode (Ctrl+A/E/K/U/W/Y, Alt+B/F/D)
  • Mobile: verify tapping terminal opens keyboard
  • Mobile: verify typing characters works
  • Mobile: verify mode defaults to EMACS on mobile
  • Mobile: verify backspace, enter, arrow keys work

Replace onKey with onData as the sole xterm.js input handler. onKey
relies on KeyboardEvent which mobile virtual keyboards don't fire;
onData receives terminal byte sequences from all input sources.

Also default to emacs mode on mobile (no Escape key on virtual
keyboards) and add tap-to-focus for opening the keyboard.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 9, 2026

🔍 Preview deployed: https://28eb0de6.qualifier-dev.pages.dev

@akesling akesling merged commit dcfbbfa into main Mar 9, 2026
2 checks passed
@akesling akesling deleted the akesling/term branch March 9, 2026 15:10
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.

1 participant