Non-blocking keybinds using threads
Project description
defKey
Non-blocking keybinds using threads.
Setup
- Download with
pip3 install defKey - Import with
import defKey
Usage
defKey allows the binding of keys to Python functions. When activated, defKey spawns a new thread which catches all keypresses (thus breaking input()) and, if they have been bound, spawns a new thread which executes the bound function. This is best for games and TUI programs.
Example
from defKey import defKey
def hello():
print("hello")
def goodbye():
print("goodbye")
def actualGoodbye():
defKey.stop()
defKey.bind("h", hello)
defKey.bind("g", goodbye)
defKey.bind("q", actualGoodbye)
defKey.start()
You must call defKey.stop() before using input(). Binds will be retained and defKey can be restarted after.
All contributions are welcome by pull request or issue.
defKey is licensed under GNU General Public License v3.0. See LICENSE for full text.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file defKey-1.0.1-py3-none-any.whl.
File metadata
- Download URL: defKey-1.0.1-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62b9ee9f8248c3c61a8763878ad85120da842bbebb187b31d57978a6539ce5a9
|
|
| MD5 |
9e6c66003f608c13e6b23c3bf04b9e69
|
|
| BLAKE2b-256 |
4360ac1991cb77000d0265d0c28900c1483540f137540c545b96951948b6f44b
|