GithubHelp home page GithubHelp logo

Comments (9)

JohannesKlauss avatar JohannesKlauss commented on June 13, 2024 1

This is a layout specific problem that gets addressed in version 5.

This has been fixed in pre release 5.0.0-1. Please try out this version.
To listen to # use you just use useHotkeys('#', callback, {useKey: true})

Please let me know if that fixes your issue.

from react-hotkeys-hook.

adam-vermes avatar adam-vermes commented on June 13, 2024

I have a similar issue with the '-': 'slash' key where it doesn't trigger the expected behaviour as in earlier versions. Could you please take a look at this issue? Thanks

from react-hotkeys-hook.

thediveo avatar thediveo commented on June 13, 2024

Not the OP, but it fixes the "/" slash for me; thank you very much!

from react-hotkeys-hook.

luispied avatar luispied commented on June 13, 2024

Hi @JohannesKlauss I recently update to version 5.0.0-1 and tried to see if that fixed my issue, but it doesn't.
I was using ignoreModifiers on the callback for the hook so when I tried to input / in different keyboard distribution it worked, but now it stoped working, so I read about the new option useKey that will probably helped me to achieve the same and sadly it does not.
Idk if im doing something wrong but would be great if you can explain me how can I achieve this behavior with all the new changes in this new version.

To be clear and have a use case for you to reproduce it, I selected the key / to trigger an action, it works perfectly in U.S English distribution in Mac, but then I changed the distribution to for example Canadian French CSA and it doesn't worked, even sending useKey:true. I tried a combination between useKey and ignoreModifiers but same result.

from react-hotkeys-hook.

JohannesKlauss avatar JohannesKlauss commented on June 13, 2024

This is the way to use special characters that are different on different layouts:

https://codesandbox.io/p/sandbox/lucid-ioana-c8zjcj

Please let me know if that works for you.

from react-hotkeys-hook.

luispied avatar luispied commented on June 13, 2024

This is the way to use special characters that are different on different layouts:

https://codesandbox.io/p/sandbox/lucid-ioana-c8zjcj

Please let me know if that works for you.

@JohannesKlauss Is what I did, but even in your sandbox I see the same issue as I have.

Perhaps I didn't explain myself correctly, what I want is that no matter the distribution when I press they key in the english keyboard / I want to trigger the callback, so for french canadian the key in the same position of the keyboard is é.

As I said I could achieved this behavior in the past using ignoreModifiers but somehow perhaps useKey and ignoreModifiers cancel this functionality themselves.

from react-hotkeys-hook.

JohannesKlauss avatar JohannesKlauss commented on June 13, 2024

Ah I see. Actually I have to look into ignoreModifiers, good chance that this option gets removed in version 5. To achieve this you would listen to the code of the key, in this case Slash:

useHotkeys("Slash", () => setCount(count + 1));

This way, no matter the keyboard layout, it will always listen to the key which is the slash key in US layout.

from react-hotkeys-hook.

luispied avatar luispied commented on June 13, 2024

Ah I see. Actually I have to look into ignoreModifiers, good chance that this option gets removed in version 5. To achieve this you would listen to the code of the key, in this case Slash:

useHotkeys("Slash", () => setCount(count + 1));

This way, no matter the keyboard layout, it will always listen to the key which is the slash key in US layout.

I forgot about slash, I tried before.

The good news is that worked for me, so thank you so much @JohannesKlauss.

Can I suggest to add this to documentation as a use case, because I didn't see it there and would be very helpful for other devs.

Also I would want to suggest if it's possible to include the types for all the key strokes in the call of the hook, as useHotkeys(keys: KeysType[], callback, options). You have a link to another library that did that in the documentation, perhaps include it inside the library will improve the use of it and reduce the errors.

from react-hotkeys-hook.

JohannesKlauss avatar JohannesKlauss commented on June 13, 2024

Well version 5.0.0 is not officially out yet, I am currently overhauling the docs, but yes, this will be documented.

I am unsure about the typings, because the keys type can be a lot of different things.

from react-hotkeys-hook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.