Skip to main content

Utilities to read single characters and key-strokes

Project description

VERSION DOWNLOADS TESTS COVERAGE
Latest PyPI version Number of PyPI downloads Travis results Coveralls results_

Library to easily read single chars and key strokes.

Goal and Philosophy

Born as a python-inquirer requirement.

The idea is to have a portable way to read single characters and key-strokes.

Documentation

Installation

pip install readchar

The readchar library is compatible with python 2.6, 2.7, 3.2 and 3.3.

Usage

Usage example:

import readchar

c = readchar.readchar()
key = readchar.readkey()

API

There are just two methods:

readchar()

Reads the next char from stdin, returning it as a string with length 1.

readkey()

Reads the next key-stroke from stdin, returning it as an string.

A key-stroke can have:

  • 1 character for normal keys: ‘a’, ‘z’, ‘9’…
  • 2 characters for combinations with ALT: ALT+A, …
  • 3 characters for cursors: ->, <-, …
  • 4 characters for combinations with CTRL and ALT: CTRL+ALT+SUPR, …

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.

License

Copyright (c) 2014 Miguel Ángel García (@magmax9).

Licensed under the MIT license.

Project details


Release history Release notifications

History Node

0.7

History Node

0.6

History Node

0.5

History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.2c

History Node

0.1.0

History Node

0.0.9

History Node

0.0.8

This version
History Node

0.0.1

History Node

0.2-test2

History Node

0.2-test1

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page