Skip to content

feat: add keyboard-based copy/cut for input field selection #7516

Closed as not planned

Description

@flexiondotorg

Problem

Currently, the input field supports keyboard-based text selection via Shift+Arrow keys and other input_select_* keybindings, but there is no way to copy or cut the selected text using the keyboard. Users must resort to mouse selection to copy text to the clipboard, which breaks keyboard-centric workflows.

While mouse selection works well and automatically copies to clipboard via OSC52, power users who prefer keyboard navigation have no equivalent functionality.

Current Workarounds

  1. Use mouse to select text (automatically copied)
  2. Use Ctrl+Y to copy console-level selections (but this doesn't work for textarea keyboard selections)

Proposed Solution

Add two new keybindings that work with keyboard-based text selection in the input field:

  • input_copy (default: Ctrl+Shift+C) - Copy selected text to clipboard
  • input_cut (default: Ctrl+Shift+X) - Cut selected text to clipboard (copy + delete)

Implementation Details

The implementation follows the established pattern of input_paste and input_clear:

  1. Config Schema: Add keybind definitions to config.ts

  2. Event Handlers: Add handlers in prompt/index.tsx that:

    • Check for active selection using input.hasSelection()
    • Retrieve selected text using input.getSelectedText()
    • Copy to clipboard using existing Clipboard.copy() utility
    • For cut: delete selection using input.deleteChar()
  3. Key Technical Points:

    • Uses TextareaRenderable's public API only
    • Leverages existing cross-platform Clipboard utility
    • Includes error handling with console logging
    • Prevents default event handling when operations succeed
    • No breaking changes (new optional keybindings with sensible defaults)

Benefits

  • ✅ Enables fully keyboard-centric workflow
  • ✅ Follows CUA (Common User Access) standard conventions
  • ✅ Consistent with standard text editors (VS Code, Sublime, etc.)
  • ✅ No breaking changes (purely additive)
  • ✅ Cross-platform compatible (uses existing Clipboard utility)
  • ✅ Works with all existing selection keybindings (Shift+Arrow, Ctrl+Shift+Home, etc.)

Default Keybindings Rationale

  • Ctrl+Shift+C for copy: Standard terminal copy binding, avoids conflict with input_clear (Ctrl+C)
  • Ctrl+Shift+X for cut: Safe binding that doesn't conflict with leader key patterns

Both are easily customizable via the config file.

Testing Plan

  1. Select text using Shift+Arrow keys
  2. Press Ctrl+Shift+C and verify text is copied to clipboard
  3. Paste elsewhere and verify copied content
  4. Select text and press Ctrl+Shift+X
  5. Verify text is copied to clipboard AND deleted from input
  6. Test with custom keybindings in config file
  7. Verify no conflicts with existing keybindings

Note: I am currently working on a pull request for this feature.

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Jan 9, 2026
  2. github-actions commented on Jan 9, 2026

    @github-actions
    Contributor

    For keybind-related issues, please also check our pinned keybinds documentation: #4997

  3. added a commit that references this issue on Feb 23, 2026
    986418e
  4. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  5. sackosh commented on Aug 26, 2026

    @sackosh

    +1, this would be very useful — especially on Windows, where terminal-level
    copy can't see the TUI editor selection made with Shift+arrows.

    @flexiondotorg's PR #7520 already implemented exactly this (input_copy /
    input_cut, CUA defaults Ctrl+Insert / Shift+Delete) with passing tests.
    It was auto-closed by the stale bot on April 25 without a maintainer review.

    Could this be revisited? Happy to help test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions