question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there any way to stop read_hotkey() programmatically?

See original GitHub issue

read_hotkey() will block and wait user presses and releases a hotkey, but is there any way to stop it with program?

I’m working on a program which allows users to input a hotkey from keyboard, and push a button to cancel hotkey input. So I need to stop blocking when the “cancel” button is pushed.

I have read whole API doc but can’t find a method to do it. Is anyone has an idea? Or maybe I miss something in the doc?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bopprehcommented, Aug 30, 2021

That’s exactly what I was suggesting! Not a bad idea at all.

You could make the solution a bit cleaner by using a threading.Event object instead of an array holding a boolean. This would help communicating to future programmers (including yourself in the future) how this feature works; but the actual bytecode that will be executed is practically identical.

I actually use something similar in the hotkey hooks with a custom class and adding extra attributes, but in that case it’s not justified and feels hacky. The new version won’t have that anymore.

0reactions
bopprehcommented, Aug 31, 2021

Good luck!

I’ll go ahead and close the ticket. The answer to the title question is “not yet, but it’s planned”.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Stop a Python Script (Keyboard and Programmatically)
One of the most common methods to stop a script is by using the following keyboard shortcut, which is known as KeyboardInterrupt :....
Read more >
How do I programmatically get the shortcut keys reserved by ...
One thing I want to do is warn if a shortcut key is chosen that is already in use by Mac OS X....
Read more >
Manage shortcuts | Android Developers
Disable shortcuts · disableShortcuts() , which removes the specified shortcuts from the static and dynamic shortcuts list and disables any pinned ...
Read more >
Programmatic shortcuts manipulation - part 1
So a very easy way to programmatically affect the shortcuts is to update ... remove the possibly-existing shortcut using removeShortcut() ...
Read more >
Customize keyboard shortcuts - Microsoft Support
Press the SHIFT+TAB key repeatedly until the cursor is in the Current keys box. Press DOWN ARROW or UP ARROW to select the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found