Skip to content

fix: prevent modifier-key combos (Ctrl+C, Ctrl+S) from triggering single-key shortcuts#359

Merged
wyuc merged 1 commit intoTHU-MAIC:mainfrom
YizukiAme:fix/358-ctrl-c-toggles-sidebar
Apr 4, 2026
Merged

fix: prevent modifier-key combos (Ctrl+C, Ctrl+S) from triggering single-key shortcuts#359
wyuc merged 1 commit intoTHU-MAIC:mainfrom
YizukiAme:fix/358-ctrl-c-toggles-sidebar

Conversation

@YizukiAme
Copy link
Copy Markdown
Contributor

Summary

Fixes #358Ctrl+C (copy), Ctrl+S (save), and other modifier-key combinations were incorrectly intercepted by the global keyboard shortcut handler in Stage, toggling UI panels instead of performing their native browser actions.

Problem

The onKeyDown handler in components/stage.tsx matches single-letter keys (c, s, m) without checking for modifier keys. When a user presses Ctrl+C:

  1. event.key'c' ✅ matches the case 'c' branch
  2. event.ctrlKeytrue ⚠️ not checked
  3. event.preventDefault() blocks the native copy action
  4. setChatAreaCollapsed(!chatAreaCollapsed) toggles the chat sidebar
Combination Expected Actual (before fix)
Ctrl+C Copy Toggles chat sidebar
Ctrl+S Save Toggles scene sidebar
Ctrl+M Browser shortcut Toggles TTS mute
⌘+C / ⌘+S (macOS) Copy / Save Same issue via metaKey

Fix

Add a single modifier-key guard at the top of the onKeyDown handler:

if (event.ctrlKey || event.metaKey || event.altKey) return;

This lets all modifier-key combinations pass through to the browser while preserving bare-key shortcuts (c, s, m, arrows, space, escape).

Risk Assessment

Minimal. No existing shortcut in this handler is designed to work with Ctrl/Meta/Alt. The guard only affects key events that were never intended to be captured.

@YizukiAme YizukiAme force-pushed the fix/358-ctrl-c-toggles-sidebar branch from 530209b to d2b3d87 Compare April 4, 2026 04:41
Ctrl+C, Ctrl+S, Ctrl+M (and ⌘ equivalents on macOS) were incorrectly
intercepted by the global keydown handler in Stage, toggling the chat
sidebar, scene sidebar, or TTS mute instead of performing their native
browser actions (copy, save, etc.).

Add a modifier-key guard at the top of onKeyDown so that any key
combination involving Ctrl, Meta, or Alt is passed through to the
browser.

Fixes THU-MAIC#358
@YizukiAme YizukiAme force-pushed the fix/358-ctrl-c-toggles-sidebar branch from d2b3d87 to 3e76d90 Compare April 4, 2026 04:53
Copy link
Copy Markdown
Contributor

@wyuc wyuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, LGTM

@wyuc wyuc merged commit fda8312 into THU-MAIC:main Apr 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ctrl+C (copy) incorrectly toggles chat sidebar instead of copying text

2 participants