I'm trying to toggle caps lock on/off when the two shift buttons are held down for a second. I've tried using the virtkey module, but it's not working. That module does work for other keys though, so I don't think I'm using the module incorrectly.
Does anybody have a way for doing this?
Just to be clear, I want to actually toggle caps lock on/off and not just the LED.
Thanks!
This works for me (turns the led on and off as well as enable/disable caps)
import virtkey
v = virtkey.virtkey()
v.press_keycode(66)
v.release_keycode(66) # first release doesn't release it
v.release_keycode(66)
Here are some more examples
v.press_keycode(66) # turns capslock on
v.release_keycode(66)
v.press_keycode(66) # turns capslock off
v.release_keycode(66)
You can also get a toggle like behaviour just using release_keycode
v.release_keycode(66) # toggles capslock
v.release_keycode(66) # toggles back again capslock
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With