Support Cmd shortcuts in canvas text-edit modes

This commit is contained in:
Jage9
2026-03-02 00:24:46 -05:00
parent daa30c57aa
commit 26d6bafce0
3 changed files with 7 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
// Maintainer-controlled web client version. // Maintainer-controlled web client version.
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2) // Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
window.CHGRID_WEB_VERSION = "2026.03.01 R333"; window.CHGRID_WEB_VERSION = "2026.03.01 R334";
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid. // Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit"; window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -3502,6 +3502,7 @@ function setupInputHandlers(): void {
document.addEventListener('keydown', (event) => { document.addEventListener('keydown', (event) => {
const code = normalizeInputCode(event); const code = normalizeInputCode(event);
if (!code) return; if (!code) return;
const hasShortcutModifier = event.ctrlKey || event.metaKey;
if (!dom.settingsModal.classList.contains('hidden') && code === 'Escape') { if (!dom.settingsModal.classList.contains('hidden') && code === 'Escape') {
closeSettings(); closeSettings();
@@ -3511,18 +3512,18 @@ function setupInputHandlers(): void {
if (!state.running) return; if (!state.running) return;
if (document.activeElement !== dom.canvas) return; if (document.activeElement !== dom.canvas) return;
if (event.altKey) return; if (event.altKey) return;
if (event.ctrlKey && !isTextEditingMode(state.mode)) return; if (hasShortcutModifier && !isTextEditingMode(state.mode)) return;
if (activeTeleport && code.startsWith('Arrow')) { if (activeTeleport && code.startsWith('Arrow')) {
event.preventDefault(); event.preventDefault();
return; return;
} }
const isNativePasteShortcut = event.ctrlKey && isTextEditingMode(state.mode) && code === 'KeyV'; const isNativePasteShortcut = hasShortcutModifier && isTextEditingMode(state.mode) && code === 'KeyV';
if ((state.mode !== 'normal' || !code.startsWith('Arrow')) && !isNativePasteShortcut) { if ((state.mode !== 'normal' || !code.startsWith('Arrow')) && !isNativePasteShortcut) {
event.preventDefault(); event.preventDefault();
} }
if (event.ctrlKey && isTextEditingMode(state.mode)) { if (hasShortcutModifier && isTextEditingMode(state.mode)) {
if (code === 'KeyV') { if (code === 'KeyV') {
return; return;
} }
@@ -3551,7 +3552,7 @@ function setupInputHandlers(): void {
mode: state.mode, mode: state.mode,
code, code,
key: event.key, key: event.key,
ctrlKey: event.ctrlKey, ctrlKey: hasShortcutModifier,
shiftKey: event.shiftKey, shiftKey: event.shiftKey,
handlers: { handlers: {
nickname: handleNicknameModeInput, nickname: handleNicknameModeInput,

View File

@@ -63,6 +63,7 @@ This document is the authoritative keymap for the client.
- `Ctrl+C`: Copy current text - `Ctrl+C`: Copy current text
- `Ctrl+X`: Cut current text - `Ctrl+X`: Cut current text
- `Ctrl+V`: Paste - `Ctrl+V`: Paste
- `Cmd+A` / `Cmd+C` / `Cmd+X` / `Cmd+V` (macOS): same behavior as `Ctrl` shortcuts above
## Numeric Edit Fields ## Numeric Edit Fields