@mytec: fix und from 1.1.1

This commit is contained in:
2026-01-30 23:31:20 +02:00
parent b7d008fe26
commit 2f1126dbba

View File

@@ -40,15 +40,21 @@ export function useKeyboardShortcuts({
return;
}
// Undo/Redo: use e.code (layout-independent) as primary, e.key as fallback.
// e.key can be uppercase 'Z' with Shift, or a control char on some layouts.
// e.code is always 'KeyZ' / 'KeyY' regardless of modifier or layout.
const isZ = e.code === 'KeyZ' || e.key.toLowerCase() === 'z';
const isY = e.code === 'KeyY' || e.key.toLowerCase() === 'y';
// Undo: Ctrl+Z (or Cmd+Z on Mac)
if (modKey && e.key === 'z' && !e.shiftKey) {
if (modKey && isZ && !e.shiftKey) {
e.preventDefault();
onUndo?.();
return;
}
// Redo: Ctrl+Shift+Z or Ctrl+Y (Cmd+Shift+Z or Cmd+Y on Mac)
if (modKey && ((e.key === 'z' && e.shiftKey) || e.key === 'y')) {
if (modKey && ((isZ && e.shiftKey) || isY)) {
e.preventDefault();
onRedo?.();
return;