Form: submit on Ctrl+S (works in every terminal)#98
Merged
Conversation
Ctrl+Enter is indistinguishable from plain Enter in most terminals
(macOS Terminal.app, basic xterm, the default VS Code terminal — they
all encode both as 0x0D). Only terminals that opt into the Kitty
keyboard protocol can tell them apart. So Form's Ctrl+Enter submit
binding silently did nothing for most users.
Library change:
Form gains submit_keys, cancel_keys, and hint_text fields. Defaults:
submit_keys = { Ctrl+S, Ctrl+Enter } // Ctrl+S works everywhere
cancel_keys = { Escape }
hint_text = 'Tab: next field | Ctrl+S: submit | Esc: cancel'
handleKey iterates the binding lists instead of hard-coding one
combo. Users can replace either list with their own KeyEvent slice.
Audit of the rest of src/ and examples/ found no other multi-modifier
bindings that fail in standard terminals — Form was the only offender.
Single-modifier (Ctrl+letter, Alt+letter), Tab, Shift+Tab, arrow keys,
and the function keys all work universally.
Verified: `zig build run-form`, type into fields, press Ctrl+S — form
submits. Tests pass.
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.
Summary
You reported Ctrl+Enter not submitting the form on macOS. It's not your terminal — it's a fundamental encoding issue. Most terminals (macOS Terminal.app, basic xterm, default VS Code terminal) encode both `Enter` and `Ctrl+Enter` as the same byte (`\r` / 0x0D). Only terminals that opt into the Kitty keyboard protocol can tell them apart. So `Form`'s old `Ctrl+Enter` binding silently did nothing for most users.
Library change
`Form` gains three new fields with sensible defaults:
`handleKey` now iterates these lists instead of hard-coding the combo, so users can replace either list with their own `KeyEvent` slice.
Audit of the rest of the codebase
I grepped `src/` and `examples/` for other multi-modifier bindings that would fail in standard terminals. Form was the only offender. Everything else uses keys that work universally:
Test plan