Utilities to read single characters and key-strokes
See it at:
Library to easily read single chars and key strokes.
Born as a python-inquirer requirement.
The idea is to have a portable way to read single characters and key-strokes.
pip install readchar
readchar library is compatible with python 2.6, 2.7, 3.2 and 3.3.
import readchar c = readchar.readchar() key = readchar.readkey()
There are just two methods:
Reads the next char from
stdin, returning it as a string with length 1.
Reads the next key-stroke from
stdin, returning it as an string.
A key-stroke can have:
There is a list of previously captured chars with their names in
readchar.key, in order to be used in comparations and so on. This list is not enough tested and it can have mistakes, so use it carefully. Please, report them if found.
Sadly, this library has only being probed on GNU/Linux. Please, if you can try it in another SO and find a bug, put an issue or send the pull-request.
You can download the code, make some changes with their tests, and make a pull-request.
In order to develop or running the tests, you can do:
git clone https://github.com/magmax/python-readchar.git
pip -r requirements.txt -r requirements-dev.txt
Please, Execute the tests before any pull-request. This will avoid invalid builds.
Copyright (c) 2014 Miguel Ángel García (@magmax9).
Based on previous work on gist getch()-like unbuffered character reading from stdin on both Windows and Unix (Python recipe), started by Danny Yoo.
Licensed under the MIT license.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|readchar-0.7-py2-none-any.whl (8.2 kB) Copy SHA256 Checksum SHA256||2.7||Wheel||Sep 13, 2014|
|readchar-0.7.tar.gz (4.5 kB) Copy SHA256 Checksum SHA256||–||Source||Sep 13, 2014|
|readchar-0.7.zip (10.4 kB) Copy SHA256 Checksum SHA256||–||Source||Sep 13, 2014|