Skip to content

fix: normalize keyboard shortcuts to ignore CapsLock and Shift casing#184

Open
AdnanQuazi wants to merge 2 commits into
frappe:developfrom
AdnanQuazi:fix/keyboard-shortcut-casing
Open

fix: normalize keyboard shortcuts to ignore CapsLock and Shift casing#184
AdnanQuazi wants to merge 2 commits into
frappe:developfrom
AdnanQuazi:fix/keyboard-shortcut-casing

Conversation

@AdnanQuazi

Copy link
Copy Markdown

Description

This PR fixes a bug where global keyboard shortcuts (Ctrl+Z, Ctrl+D, Ctrl+F, etc.) would silently fail if the user had CapsLock engaged or was holding Shift. It also fixes a minor bug in useStudioEvents.ts where the canRedo function was referenced but not actually executed in the Ctrl+Shift+Z handler.

Root Cause

When CapsLock or Shift is active, KeyboardEvent.key returns the uppercase character (e.g., "Z" instead of "z"). Since the frontend used strict equality checks (e.key === "z"), these shortcuts failed to trigger under those conditions.

Changes

  • helpers.ts: Introduced an isKey(e, key) helper that normalizes casing before comparison.
  • useStudioEvents.ts: Replaced all raw .key alphabet checks with isKey().
  • SearchBlock.vue & ComponentInterface.vue & StudioRightPanel.vue: Applied the isKey() helper to local shortcuts (Ctrl+F and Ctrl+S) for consistency.
  • Redo Fix: Changed canRedo to canRedo() to ensure the redo stack check actually evaluates.

Testing

  • Enable CapsLock and verify that Ctrl+Z (Undo), Ctrl+Shift+Z (Redo), Ctrl+D (Duplicate) and other shortcuts work correctly on the canvas.

@AdnanQuazi

Copy link
Copy Markdown
Author

@ruchamahabal Please review this PR.

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.

1 participant