Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defineShortcut - minus button does not work #954

Closed
appinteractive opened this issue Nov 12, 2023 · 6 comments · Fixed by #962
Closed

defineShortcut - minus button does not work #954

appinteractive opened this issue Nov 12, 2023 · 6 comments · Fixed by #962
Labels
bug Something isn't working

Comments

@appinteractive
Copy link

appinteractive commented Nov 12, 2023

Environment

  • Operating System: Darwin
  • Node Version: v18.16.1
  • Nuxt Version: 3.8.1
  • CLI Version: 3.9.1
  • Nitro Version: 2.7.2
  • Package Manager: pnpm@8.7.0
  • Builder: -
  • User Config: devtools, modules, ui, colorMode
  • Runtime Modules: @nuxt/ui@2.10.0, @nuxtjs/tailwindcss@6.9.4, @vueuse/nuxt@10.6.0
  • Build Modules: -

Version

v3.8.1

Reproduction

defineShortcuts({
  "+": {
    handler: () => {
      console.log("WORKS");
    },
  },
  "-": {
    handler: () => {
      console.log("DOES NOT WORK AT ALL");
    },
  },
})

Description

I try to get the minus key - working on my QWERTZ keyboard with defineShortcuts but it will not get triggered at all.
I tried minus, - and copied the exact key code to be sure that the character is not altered in any way but still no luck. The plus button works like a charm, though.

Context:

My goal is to use Shift + - for my shortcut in the end, this reproduction got rid of it for testing.
I tried shift_- in the first place and later used the whenever key in combination with the useKeyModifier("Meta") from vue-use.

Additional context

German Keyboard, QWERTZ.

Logs

No response

@appinteractive appinteractive added the bug Something isn't working label Nov 12, 2023
Copy link
Contributor

Hi @appinteractive,

Thanks for the feedback, indeed - not working is a bug, and yes - is the right key. I made a PR to fix this issue.

However, I'm a bit confused about the combination of shift and -.
Theoretically, you would only have to define the key that is actually output by the system.
Meaning that, let's say for a qwerty mac layout, you have the keyboard key [ / | ? ] (? being on top and activated with Shift). If you want to have a shortcut on ?, you simply need to define the key ?. If you define shift_slash, it won't match since when you hit Shift, the other key will be ? and not /.

I explain that just to be sure we are on the same page. Do you try to use Shift in combination of Minus to detect the "on top" key?
If I'm understanding the german layout correctly, _ is on top of -, so you would simply want to define the _ shortcut.

@appinteractive
Copy link
Author

appinteractive commented Nov 13, 2023

Hey @smarroufin thanks for your response. Exactly because I can't predict the character that is on the keyboard when pressing shift due to different layouts. I want the combination to always work, regardless of the keyboard layout.

It's something that is often overlooked, for example a lot of sites use / for the search or command pallets, but on a German Keyboard Layout you have to press shift + 7 to get the / key which often breaks in such cases.

But with this particular issue here, none of the combinations with - work, not meta, control or even plain - do anything.

Copy link
Contributor

Ok, so in the first place my fix should be solving the - issue 👌
I think we should let it be in the next release if possible @benjamincanac 🙏


And for your usecase @appinteractive, I have to say it's quite complex to handle, we will have to think of another "mode" to interpret shortcuts.
How we thought about it is, whatever the kb layout, we want to focus on the result key. So for example ?, we make the dev write it ?, and don't care if it's achieved through ? or shift+/.
But in your case, if I understood correctly, you would like to force a combination shift+something, and whatever the result is, it has be triggered with that combination.

I guess this is another way of interpreting things. And I unfortunately don't think of an easy/quick way of doing this. This will have to be kind of a feature/improvement.

@appinteractive
Copy link
Author

But in your case, if I understood correctly, you would like to force a combination shift+something, and whatever the result is, it has be triggered with that combination.

Yes, think of a floor plan editor, you want to be able to use more than one key in combination. That's a common use case for tools. Sadly, I can't find any reasonable source for best practices in that regard.

Copy link
Contributor

I got you, totally legit usecase!
And I'm sorry to disappoint, it may not happen in the short term. Hopefully, it will somedays with the growth of UI and its community 🙏

@appinteractive
Copy link
Author

I'm happy enough when the minus character works, as the rest is possible with the "whenever" prop already! 🥇

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants