#๐ keyboard module help
12 messages ยท Page 1 of 1 (latest)
@dense lava
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
can you provide the code
keyboard.add_hotkey('ctrl+t', self.command)
def on_key_event(self,event):
if event.event_type == keyboard.KEY_DOWN:
if event.name == 't' and keyboard.is_pressed('ctrl'):
self.ctrl_t_vissza_test()
return False
keyboard.hook(self.on_key_event)
I try with this solution
With this code working fine,
But this code run every time when i press any buttons ๐
!code
What code do you have for self.ctrl_t_vissza_test()
Is your concern that the bind won't work after you're on the lock screen view or that it doesn't work after unlocking the screen?
Sometimes hooks won't reinitialize properly after locking, you could try this pattern instead if your concern is that things fail after unlocking your session
import keyboard
def ctrl_t_vissza_test():
pass
def on_key_event(event):
if event.event_type != 'down':
return
if event.name == 't' and keyboard.is_pressed('ctrl'):
ctrl_t_vissza_test()
keyboard.hook(on_key_event)
keyboard.wait()
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.