Repository navigation
Conversation
RN's TextInput only surfaces printable characters and Backspace on iOS, so a
physical Ctrl, Alt, arrow, Esc, Tab, or function key produced no JS event and
never reached the PTY — a hardware keyboard on iPad could only type text.
Add an expo-hardware-keyboard native module (iOS Swift + Android Kotlin) that
captures raw hardware key presses and forwards {key, modifiers} to JS, where the
existing buildTerminalShortcutKey() encodes the control bytes and the existing
sendLiveTerminalInput() delivers them. Wire a "physical keyboard" toggle into
the terminal session screen as a third input mode alongside buffered and live.
The byte-encoding reuses the audited terminal-accessory-keys logic; only the
native event source is new. terminal-hardware-key.ts is covered by unit tests.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Contributor
Author
|
Withdrawing until verified on-device — the native key-capture paths haven't been built and tested on a real iPad yet. Branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
On an iPad with an attached hardware keyboard, the mobile terminal can only send printable text. A physical
Ctrl,Alt, arrow,Esc,Tab, or function key does nothing — so you can'tCtrl-Ca process, navigate shell history, or drive a TUI without tapping the on-screen accessory bar (which forces you to stop typing).Root cause: keystrokes are forwarded through a hidden
TextInputcapture field, and iOS only delivers two things from it — printable characters (onChangeText) and Backspace (onKeyPress, viagetTerminalLiveSpecialKeyBytes). Modifier combos and special keys never produce a usable JS event, so they're dropped.This PR captures hardware key events at the native layer and routes them into the existing terminal-send pipeline.
How it works
The encoding was already solved —
buildTerminalShortcutKey()interminal-accessory-keys.tsturns any{key, modifiers}into the correct control bytes (Ctrl→control char, arrows→CSI, F1–F4→SS3, etc.), and the accessory-bar buttons already use it. The only missing piece was a source of hardware key events.@orca/expo-hardware-keyboard(mirrorsexpo-two-way-audio): a nativeExpoViewthat becomes first responder whenactiveand forwards raw presses.pressesBegan(UIKey:keyCode,characters,modifierFlags). Not a text input, so the software keyboard stays hidden while focused — correct for a hardware-keyboard iPad.dispatchKeyEvent; resolves special keys + base char natively.terminal-hardware-key.tsmaps a native event →{key, modifiers}(iOS HID keycodes resolved in JS; Android pre-resolved) and calls the existing encoder. Unit-tested.No existing input path changes — this is purely additive.
Verification
terminal-hardware-key.test.ts— covers Ctrl+C, Ctrl+A, Alt+b, all arrows, Ctrl+Arrow, Esc, Tab, Shift+Tab, Backspace, Enter, F5, PageUp, Home, plus the Android pre-resolved path. The byte expectations were checked against the realbuildTerminalShortcutKey.Build & confirm on iPad (dev client)
On-device checklist:
Ctrl-Cinterrupts; arrows recall/move;Esc,Tab,Ctrl-Rwork in a shell and a TUI (e.g.htop,vim).Known limitations (follow-ups)
applyShifttable; worth a spot-check on device.isHardwareKeyboardConnected()(already exported by the module).🤖 Generated with Claude Code