useKeyModifier: CapsLock does not get set back to false directly
See original GitHub issueI use const capsLockState = useKeyModifier('CapsLock')
to detect if the caps lock is currently active or not.
On first press it activates correctly, but on second press (turning it off again) it doesn’t get set to false
directly.
After a click on the website or pressing any key after disabling, it turns to false
.
I can reproduce this in the Demo: https://vueuse.org/core/useKeyModifier
Using an Ubuntu 20.04 with Chrome 97.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
useKeyModifier - VueUse
Reactive Modifier State. Tracks state of any of the supported modifiers - see Browser Compatibility notes. Demo #. source. capsLock. numLock. scrollLock.
Read more >How do you tell if caps lock is on using JavaScript?
You can detect caps lock using "is letter uppercase and no shift pressed" using a keypress capture on the document ...
Read more >CAPS LOCK woes · Issue #2350 · Hammerspoon ... - GitHub
Is there any way, using only Hammerspoon, to set up CAPS LOCK to act ... if hs.hid.capslock.get() then hs.hid.capslock.set(false) hs.alert.
Read more >How to fix Caps Lock indicator not working on Windows 10/11?
Make sure you know the exact details of your device and is aware what you should look for, since downloading and installing a...
Read more >Caps lock always turn on after switching from Wind...
I have a really annoying problem since I upgraded to vmware fusion 10 ... in my original keyboard, the Caps Lock Key was...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @Shinigami92. I wrote this useKeyModifier function and just want to let you know the reason behind ‘bug 1’ - why the state is updated on ANY key press. If you imagine the following situation in the case that we only updated on the modifier key being pressed:
Hope that makes sense. No matter what key you press, the event exposes the current modifier state of all modifier keys via the getModifierState function.
You can add more listeners to update the state more regularly, at the cost of performance. e.g. mousemove events also provide modifier states - see https://github.com/vueuse/vueuse/pull/698#issuecomment-908241915
In terms of picking up the initial modifier state on page load, I looked into this at the time and couldn’t find a way to do it. If you simulate a key press through JS, all the modifier states are false. They are only populated on a ‘real’ keyboard event - SO thread
Strange, I’m unable to reproduce on my end