Skip to main content

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

  1. Full Unicode support
  2. Blocking and non-blocking key press reading
  3. Cross-platform support
  4. Basic hotkeys ( CTRL-V or ALT-A ) are defined
  5. Not interruptable key press reading support ( cannot be interrupted by CTRL-C, returns key code instead )
  6. Keys as 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()

License

getchlib is licensed under GPL License

Project details


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.0.12.tar.gz (12.4 kB view details)

Uploaded Source

File details

Details for the file getchlib-1.0.12.tar.gz.

File metadata

  • Download URL: getchlib-1.0.12.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.4.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for getchlib-1.0.12.tar.gz
Algorithm Hash digest
SHA256 a8c8dcdf513c67f51b752b821422115f1f8c649613aa3a6feeddfa9cad7a3150
MD5 82000dac0cc14cf10555076d76ba14a3
BLAKE2b-256 9c990e9bdab19753478aa78fa7ea0acddf86e6c9ea5c73d500fd7724f6ed6fb4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page