Skip to content

Linux type_characters for characters off the keyboard layout (keymap remapping) #226

Open

Description

@SSFSKIM

Problem & intent

type_characters (added by OpenAI's newest Linux helper, 26.1023.51421; built into cua's engine by #171 M2) types only characters the current keyboard layout can produce, and refuses the first one it cannot. In the vendor build, "éΩ🙂" on a US layout failed at é (resolve_keys failed xlib::XKeysymToKeycode keysym=0xe9); no remapping was observed (#171 research F §6.4).

Committed Unicode text already works through type_text, which pastes through the clipboard (#171's verified paste route). Paste is not always what a target accepts: fields that block paste, applications that react to key events rather than inserted text (terminals, canvas editors, games, key-driven filters), and callers that must not touch the clipboard at all.

Intent: type_characters types any Unicode character as key events, on the background route, without the clipboard.

Known approach and its costs

The established X11 technique binds a spare keycode to the needed keysym (ChangeKeyboardMapping), sends the press and release, and restores the mapping.

  • The keymap is global to the X server: for the duration, the person's own typing on a shared desktop can be affected.
  • Every change sends MappingNotify, and each client refetches its keymap. A client that has not refetched when the key event arrives translates it with the old mapping and types the wrong character, so delivery needs a confirmation or a wait that is known to be safe.
  • The mapping must be restored on every path, including an engine crash, and two engines must not remap at once (a cross-engine lock, like Independence 4b: cua's own Linux native engine (replace sky_linux), after #117's macOS engine #171's clipboard lock).
  • On the background route the event carries a keycode and modifier state that the target translates with its own keymap copy, so that copy must be current.
  • Input methods may intercept the events.

On Wayland, libei's ei_text (libei 1.6) commits UTF-8 directly; that belongs to the Wayland backend ticket.

Constraints

Success criteria

  • type_characters("éΩ🙂") on a US layout produces exactly that text in gedit, Chrome and a terminal on the background route.
  • The keymap is restored afterwards, including after the engine is killed mid-call (checked by the next engine start).
  • A person typing on the same desktop during a remap gets their own characters (a harness test with concurrent key events).
  • capabilities reports text.literal as covering any Unicode character only when this works on the session.

Open questions

  1. A safe wait after MappingNotify: is there a confirmation signal per client, or only a bounded wait?
  2. In shared desktop mode, is a global keymap change acceptable at all, or is this dedicated-only?
  3. Characters needing more than one keysym (combining sequences, emoji with modifiers).

Decision log

Activity

  1. added
    enhancement
    status:ready-for-architect
    on Oct 28, 2026
  2. SSFSKIM commented on Oct 28, 2026

    @SSFSKIM
    OwnerAuthor

    [board] ready-for-architect: Backlog from #171 scope call; owner ranked below Wayland

  3. added
    priority:P3
    on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:P3status:ready-for-architect

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions