ui icon indicating copy to clipboard operation
ui copied to clipboard

Add support for non-Latin keyboard layouts in defineShortcuts composable

Open al1maher opened this issue 1 year ago • 1 comments

Description

Problem The current implementation of the keyboard shortcuts composable (defineShortcuts) doesn't work correctly with non-Latin keyboard layouts, such as Arabic. This limits the usability of the composable for users with different language settings.

Proposed Solution Implement an optional configuration flag 'layoutIndependent' that, when set to true, makes the composable use KeyboardEvent.code instead of KeyboardEvent.key. This change will allow the shortcuts to work regardless of the keyboard layout or language setting.

Additional context

No response

al1maher avatar Oct 02 '24 12:10 al1maher

Hi @al1maher 👋 ,

Could you give us a little reproduction so we can have a base to work on? Perhaps this is already fixed on v3, or we can work on it for v3 🤔

Tragio avatar Oct 03 '24 18:10 Tragio

I completely agree with the need for this improvement. Currently, I face the same issue where I have to duplicate shortcut definitions for different keyboard layouts. Here's an example from my project:

defineShortcuts({
    ctrl_b: {
      usingInput: true,
      handler: () => toggleSidebar(),
    },
    ctrl_и: {
      usingInput: true,
      handler: () => toggleSidebar(),
    },
  });

It would be incredibly helpful if defineShortcuts allowed binding based on event.code, which is independent of the active keyboard layout. This enhancement would significantly simplify handling shortcuts across different languages.

Thank you for considering this!

dvrtnkv avatar Jan 10 '25 07:01 dvrtnkv