Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Python bindings for libtermkey

Project description

pylibtermkey

PyPI Release Build Status

pylibtermkey is a set of Python bindings for libtermkey, a library for interpreting terminal input. Other Python bindings are out of date and not easily installable. This project has a few differences:

  • libtermkey is automatically built as part of this project
  • pybind11 is used for easy binding
  • unit tests are included
  • precompiled wheels are built from this repo and available on PyPI

Installation

To install from PyPI:

pip install pylibtermkey

Example

A minimal example of obtaining a keystroke and printing the results:

import pylibtermkey_cpp as termkey
tk = termkey.TermKey()

res, key = tk.waitkey()
print(res)
print(tk.strfkey(key, termkey.TermKeyFormat.VIM)

Note that, by default, termkey will read from stdin causing python terminal to not display typed characters. It is best to use termkey in an pre-written script rather in a REPL setup (as you will not be able to see what you are typing once termkey is active).

For other features, see the tests or the libtermkey man pages.

Building

To build this project:

Building from source requires cmake (pip install cmake).

python setup.py

Unit tests

To run the unit tests:

python setup.py test

or use nose:

nosetests python/pylibtermkey

Licensing

This project is licensed under the MIT license. It uses the pybind11 and libtermkey projects whose licenses can be found in those projects' directories.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pylibtermkey, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size pylibtermkey-0.3.1-cp35-cp35m-macosx_10_13_intel.whl (120.7 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size pylibtermkey-0.3.1-cp35-cp35m-manylinux2014_x86_64.whl (300.4 kB) File type Wheel Python version cp35 Upload date Hashes View
Filename, size pylibtermkey-0.3.1-cp36-cp36m-macosx_10_13_intel.whl (120.7 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pylibtermkey-0.3.1-cp36-cp36m-manylinux2014_x86_64.whl (300.4 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pylibtermkey-0.3.1-cp37-cp37m-macosx_10_13_intel.whl (120.8 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pylibtermkey-0.3.1-cp37-cp37m-manylinux2014_x86_64.whl (300.5 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pylibtermkey-0.3.1-cp38-cp38-macosx_10_13_x86_64.whl (124.3 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pylibtermkey-0.3.1-cp38-cp38-manylinux2014_x86_64.whl (299.1 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pylibtermkey-0.3.1.tar.gz (647.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page