Library for reading key presses
Project description
getchlib - library for reading key presses
Overview
getchlib
is library for reading key presses and assigning hotkeys.
Features
- Full Unicode support
- Blocking and non-blocking key press reading
- Cross-platform support
- Basic hotkeys (
CTRL-V
orALT-A
) are defined - Not interruptable key press reading support ( cannot be interrupted by
CTRL-C
, returns key code instead ) - Keys like arrow up, arrow left, arrow down, arrow right are defined (for full list, view getchlib.keynames.raw)
Installation
pip install getchlib
Usage
Key Presses
Blocking
import getchlib
key=getchlib.getkey()
Waits until user presses a key.
Non-Blocking
import getchlib
key=getchlib.getkey(False)
Returns first key pressed in time specified by its second argument tout
( 0.01 by default ).
Not interruptable
import getchlib
key=getchlib.getkey(catch=True)
Echo argument (new in v1.0.3)
With echo=True
characters readed are echoed to the screen.
key=getchlib.getkey(echo=True)
Hotkeys
import getchlib
def function():
print('hello')
f=getchlib.HotKeyListener()
f.add_hotkey('ctrl-x',function)
f.start()
Not interruptable
import getchlib
def function():
print('hello')
f=getchlib.HotKeyListener(catch=True)
f.add_hotkey('a',function)
f.start()
Non-blocking (linux only)
import getchlib
def function():
print('hello')
f=getchlib.HotKeyListener(catch=True)
f.add_hotkey('a',function)
...
f.terminate()
License
getchlib
is licensed under GPL License
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 Distribution
getchlib-1.1.1.tar.gz
(12.4 kB
view details)
Built Distribution
getchlib-1.1.1-py3-none-any.whl
(13.8 kB
view details)
File details
Details for the file getchlib-1.1.1.tar.gz
.
File metadata
- Download URL: getchlib-1.1.1.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 PyPy/7.3.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b05ca7ffee2aca9da326fae0c0ea8ded0f2df58f94f4b926100e80d5e8628f8 |
|
MD5 | 0dd8d107dd25d0a2b8755f64a32e5ee6 |
|
BLAKE2b-256 | ea67f4feeb9b3af0acdad8a1951b109f20873785090e3e3d1ac80116630c44fe |
File details
Details for the file getchlib-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: getchlib-1.1.1-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 PyPy/7.3.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2525a8ba63f81a99be67184bc4ca476deb5f702d3dc79987a0289d72777025b9 |
|
MD5 | cc9c9bf38056801a578ac377314b5b54 |
|
BLAKE2b-256 | 3232e545a0bd7af9fe5a5ca108045b3e4fa73709a89e70c1b0c04eb0770391b0 |