[GH-ISSUE #752] InputRenderable rejects non-ASCII characters (accented letters, Unicode) #975

Closed
opened 2026-03-14 09:11:05 +03:00 by kerem · 1 comment
Owner

Originally created by @Hokimisu on GitHub (Feb 27, 2026).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/752

The InputRenderable class in @opentui/core restricts text input to ASCII-only characters (codes 32-126), preventing users from typing any accented or non-ASCII characters such as French é, è, ê, à, ç, ù, ô, î, as well as characters from other languages (German ü, ö, ä, Spanish ñ, etc.).

Steps to Reproduce

  1. Use any component based on InputRenderable (e.g., a text input field)
  2. Try typing a French accented character like é or ç
  3. The character is silently ignored — nothing appears in the input

Root Cause

In packages/core/index.js, the handleKeyPress method of InputRenderable (line ~5789) has this condition:

if (key.sequence && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32 && key.sequence.charCodeAt(0) <= 126) {
  this.insertText(key.sequence);
  return true;
}

The check charCodeAt(0) <= 126 limits input to the ASCII printable range only. Any character above code point 126 is rejected. For reference:

Character Code Point Result
a 97 Accepted
z 122 Accepted
~ 126 Accepted
é 233 Rejected
è 232 Rejected
ç 231 Rejected
à 224 Rejected
ü 252 Rejected
ñ 241 Rejected

Suggested Fix

Replace the upper bound check <= 126 with !== 127 (to still exclude the DEL control character):

// Before
if (key.sequence && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32 && key.sequence.charCodeAt(0) <= 126) {

// After
if (key.sequence && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32 && key.sequence.charCodeAt(0) !== 127) {

This allows all printable Unicode characters while still filtering out control characters (< 32) and DEL (127).

Note: TextareaRenderable already uses a more permissive check that does not have this issue.

Environment

  • @opentui/core version: 0.1.73
  • OS: Windows 11
  • Terminal: Windows Terminal
  • Node.js: v22+
Originally created by @Hokimisu on GitHub (Feb 27, 2026). Original GitHub issue: https://github.com/anomalyco/opentui/issues/752 The `InputRenderable` class in `@opentui/core` restricts text input to ASCII-only characters (codes 32-126), preventing users from typing any accented or non-ASCII characters such as French `é`, `è`, `ê`, `à`, `ç`, `ù`, `ô`, `î`, as well as characters from other languages (German `ü`, `ö`, `ä`, Spanish `ñ`, etc.). ## Steps to Reproduce 1. Use any component based on `InputRenderable` (e.g., a text input field) 2. Try typing a French accented character like `é` or `ç` 3. The character is silently ignored — nothing appears in the input ## Root Cause In `packages/core/index.js`, the `handleKeyPress` method of `InputRenderable` (line ~5789) has this condition: ```javascript if (key.sequence && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32 && key.sequence.charCodeAt(0) <= 126) { this.insertText(key.sequence); return true; } ``` The check `charCodeAt(0) <= 126` limits input to the ASCII printable range only. Any character above code point 126 is rejected. For reference: | Character | Code Point | Result | |-----------|-----------|------------| | `a` | 97 | Accepted | | `z` | 122 | Accepted | | `~` | 126 | Accepted | | `é` | 233 | **Rejected** | | `è` | 232 | **Rejected** | | `ç` | 231 | **Rejected** | | `à` | 224 | **Rejected** | | `ü` | 252 | **Rejected** | | `ñ` | 241 | **Rejected** | ## Suggested Fix Replace the upper bound check `<= 126` with `!== 127` (to still exclude the DEL control character): ```javascript // Before if (key.sequence && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32 && key.sequence.charCodeAt(0) <= 126) { // After if (key.sequence && key.sequence.length === 1 && key.sequence.charCodeAt(0) >= 32 && key.sequence.charCodeAt(0) !== 127) { ``` This allows all printable Unicode characters while still filtering out control characters (< 32) and DEL (127). Note: `TextareaRenderable` already uses a more permissive check that does not have this issue. ## Environment - `@opentui/core` version: 0.1.73 - OS: Windows 11 - Terminal: Windows Terminal - Node.js: v22+
kerem 2026-03-14 09:11:05 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@simonklee commented on GitHub (Feb 27, 2026):

Please update your OpenTUI version. InputRenderable was refactored. https://github.com/anomalyco/opentui/pull/539

<!-- gh-comment-id:3975068553 --> @simonklee commented on GitHub (Feb 27, 2026): Please update your OpenTUI version. InputRenderable was refactored. https://github.com/anomalyco/opentui/pull/539
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#975
No description provided.