Skip to content

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

Open
YizukiAme wants to merge 1 commit intoTHU-MAIC:mainfrom
YizukiAme:fix/358-ctrl-c-toggles-sidebar
Open

fix: prevent modifier-key combos (Ctrl+C, Ctrl+S) from triggering single-key shortcuts#359
YizukiAme wants to merge 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.

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
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

1 participant