Skip to content

Add support for non-Latin keyboard layouts in defineShortcuts composable #2293

Open
@al1maher

Description

@al1maher

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

Activity

Tragio

Tragio commented on Oct 3, 2024

@Tragio
Contributor

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 🤔

dvrtnkv

dvrtnkv commented on Jan 10, 2025

@dvrtnkv

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!

added a commit that references this issue on May 29, 2025
d957ff6
added
wontfix-v2This will not be fixed in `v2.x`.
v3#1289
and removed on Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestv3#1289wontfix-v2This will not be fixed in `v2.x`.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @benjamincanac@Tragio@al1maher@dvrtnkv

      Issue actions

        Add support for non-Latin keyboard layouts in defineShortcuts composable · Issue #2293 · nuxt/ui