[PR #527] [CLOSED] fix: map keypad keys to printable characters in Kitty keyboard protocol #1381

Closed
opened 2026-03-14 09:33:36 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/527
Author: @alpacachen
Created: 1/15/2026
Status: Closed

Base: mainHead: fix/keypad-characters


📝 Commits (1)

  • 627fa15 fix: map keypad keys to printable characters in Kitty keyboard protocol

📊 Changes

2 files changed (+85 additions, -12 deletions)

View changed files

📝 packages/core/src/lib/parse.keypress-kitty.test.ts (+47 -0)
📝 packages/core/src/lib/parse.keypress-kitty.ts (+38 -12)

📄 Description

Summary

  • Maps keypad keys (kp0-kp9, kpplus, kpminus, etc.) to their printable character equivalents
  • Adds comprehensive test cases for keypad character generation

Problem

When using Kitty keyboard protocol, keypad keys are correctly identified with names like kp0, kp1, kpplus, etc., but the sequence field doesn't contain the corresponding printable character. This causes input fields (textarea, input) to not accept keypad input since they rely on the sequence to insert text.

For example:

  • Main keyboard 1 produces: name="1", sequence="1"
  • Numpad 1 produces: name="kp1", sequence="\x1b[57401u" ✗ (should be "1")

Solution

Added a keypadCharMap to convert keypad key names to their printable character equivalents:

  • kp0-kp9"0"-"9"
  • kpplus"+"
  • kpminus"-"
  • kpmultiply"*"
  • kpdivide"/"
  • kpdecimal"."
  • kpequal"="

Note: kpenter is intentionally NOT mapped since it should behave like the return key, not insert a character.

Testing

Added test cases to verify keypad keys produce the correct characters in their sequence field.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/527 **Author:** [@alpacachen](https://github.com/alpacachen) **Created:** 1/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/keypad-characters` --- ### 📝 Commits (1) - [`627fa15`](https://github.com/anomalyco/opentui/commit/627fa154a4fb01930dede4593602b5ba217ead0e) fix: map keypad keys to printable characters in Kitty keyboard protocol ### 📊 Changes **2 files changed** (+85 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/lib/parse.keypress-kitty.test.ts` (+47 -0) 📝 `packages/core/src/lib/parse.keypress-kitty.ts` (+38 -12) </details> ### 📄 Description ## Summary - Maps keypad keys (kp0-kp9, kpplus, kpminus, etc.) to their printable character equivalents - Adds comprehensive test cases for keypad character generation ## Problem When using Kitty keyboard protocol, keypad keys are correctly identified with names like `kp0`, `kp1`, `kpplus`, etc., but the `sequence` field doesn't contain the corresponding printable character. This causes input fields (textarea, input) to not accept keypad input since they rely on the sequence to insert text. For example: - Main keyboard `1` produces: `name="1"`, `sequence="1"` ✓ - Numpad `1` produces: `name="kp1"`, `sequence="\x1b[57401u"` ✗ (should be `"1"`) ## Solution Added a `keypadCharMap` to convert keypad key names to their printable character equivalents: - `kp0`-`kp9` → `"0"`-`"9"` - `kpplus` → `"+"` - `kpminus` → `"-"` - `kpmultiply` → `"*"` - `kpdivide` → `"/"` - `kpdecimal` → `"."` - `kpequal` → `"="` Note: `kpenter` is intentionally NOT mapped since it should behave like the return key, not insert a character. ## Testing Added test cases to verify keypad keys produce the correct characters in their sequence field. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-14 09:33:36 +03:00
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#1381
No description provided.