[GH-ISSUE #412] Console +/- resize keys unreliable across terminal protocols #876

Open
opened 2026-03-14 08:54:12 +03:00 by kerem · 0 comments
Owner

Originally created by @edlsh on GitHub (Dec 13, 2025).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/412

Description

The + and - keys for resizing the console window do not work reliably. The issue is intermittent and depends on the terminal emulator and keyboard protocol in use.

Root Cause Analysis

The key handling in packages/core/src/console.ts (lines 480-485) checks:

} else if (event.name === "+" || (event.name === "=" && event.shift)) {
  this.options.sizePercent = Math.min(100, this.options.sizePercent + 5)
  this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight)
} else if (event.name === "-") {

Issues identified:

  1. Kitty keyboard protocol inconsistency: When Kitty protocol is enabled, terminals may send the base key codepoint (= with shift modifier) rather than the shifted result (+). In parse.keypress-kitty.ts, key.name is set from String.fromCodePoint(codepoint) and the shifted codepoint only updates text, not key.name.

  2. US keyboard layout assumption: The + key requires Shift+= on US keyboards. Different terminals handle this differently:

    • Raw mode: Sends literal + character
    • Kitty protocol: May send codepoint 61 (=) with shift flag, or codepoint 43 (+)
  3. No keypad support: Numeric keypad + and - keys (codes 57413/57414 in Kitty) are mapped to kpminus/kpplus but not handled by the console.

Suggested Fix

Normalize key detection to handle all variants:

const isPlus = event.name === "+" || 
               (event.name === "=" && event.shift) ||
               event.name === "kpplus"

const isMinus = event.name === "-" || 
                event.name === "kpminus"

if (isPlus) {
  this.options.sizePercent = Math.min(100, this.options.sizePercent + 5)
  this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight)
} else if (isMinus) {
  this.options.sizePercent = Math.max(10, this.options.sizePercent - 5)
  this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight)
}

Environment

  • Affected file: packages/core/src/console.ts
  • Related files: packages/core/src/lib/parse.keypress.ts, packages/core/src/lib/parse.keypress-kitty.ts
Originally created by @edlsh on GitHub (Dec 13, 2025). Original GitHub issue: https://github.com/anomalyco/opentui/issues/412 ## Description The `+` and `-` keys for resizing the console window do not work reliably. The issue is intermittent and depends on the terminal emulator and keyboard protocol in use. ## Root Cause Analysis The key handling in `packages/core/src/console.ts` (lines 480-485) checks: ```typescript } else if (event.name === "+" || (event.name === "=" && event.shift)) { this.options.sizePercent = Math.min(100, this.options.sizePercent + 5) this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight) } else if (event.name === "-") { ``` ### Issues identified: 1. **Kitty keyboard protocol inconsistency**: When Kitty protocol is enabled, terminals may send the base key codepoint (`=` with shift modifier) rather than the shifted result (`+`). In `parse.keypress-kitty.ts`, `key.name` is set from `String.fromCodePoint(codepoint)` and the shifted codepoint only updates `text`, not `key.name`. 2. **US keyboard layout assumption**: The `+` key requires Shift+= on US keyboards. Different terminals handle this differently: - Raw mode: Sends literal `+` character - Kitty protocol: May send codepoint 61 (`=`) with shift flag, or codepoint 43 (`+`) 3. **No keypad support**: Numeric keypad `+` and `-` keys (codes 57413/57414 in Kitty) are mapped to `kpminus`/`kpplus` but not handled by the console. ## Suggested Fix Normalize key detection to handle all variants: ```typescript const isPlus = event.name === "+" || (event.name === "=" && event.shift) || event.name === "kpplus" const isMinus = event.name === "-" || event.name === "kpminus" if (isPlus) { this.options.sizePercent = Math.min(100, this.options.sizePercent + 5) this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight) } else if (isMinus) { this.options.sizePercent = Math.max(10, this.options.sizePercent - 5) this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight) } ``` ## Environment - Affected file: `packages/core/src/console.ts` - Related files: `packages/core/src/lib/parse.keypress.ts`, `packages/core/src/lib/parse.keypress-kitty.ts`
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#876
No description provided.