Comments (9)
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.
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.
Not the OP, but it fixes the "/" slash for me; thank you very much!
from react-hotkeys-hook.
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.
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.
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.
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.
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 caseSlash
: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.
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)
- [BUG] meta on Mac does not capture cmd like the docs say HOT 3
- What is v4.5.0? HOT 1
- [BUG] Working locally, but not in production HOT 6
- [BUG]The keyboard combination doesn't work in focused input HOT 2
- [PSA] You probably want `equal` instead of `+` (plus/bracketright) HOT 1
- The useRecordHotkeys hook should allow us to programatically set the keys HOT 1
- [BUG] Does not handle the 'Alt Graph' modifier key HOT 1
- Match a key pressed by character (optionally maybe) instead of keyCode HOT 1
- [BUG] Hotkeys stuck on `contextmenu` event. HOT 1
- Several entries in mappedKeys look suspicious HOT 2
- [BUG] preventDefault seems not work when use `command + s ` HOT 2
- [BUG] Why is # key mapped to Backslash HOT 1
- [BUG] Callback called on each matched key in array HOT 3
- [BUG] hotKeys trigger from input inside WebComponent HOT 2
- [BUG] isHotkeyPressed requires ALL buttons to be pressed, not just at least one
- [BUG] v5.0.0-1, "useKey" option also seems to (partially) activate "ignoreModifiers" HOT 3
- [BUG] don't trigger hot keys when input focus HOT 1
- [BUG] `mod` modifier listens to `ctrl` on macOS
- [BUG] document property of options param in useHotkeys method not working
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-hotkeys-hook.