This library allows easy processing of keyboard entry from terminal-based programs. It handles all the necessary logic to recognise special keys, UTF-8 combining, and so on, with a simple interface.


Note: Use of this library for new programs is discouraged. It is being maintained for legacy purposes only. For writing new programs, please use libtickit instead.

All of the code in this library will be migrated into libtickit in due course; currently it is used via an internal dependency.

It provides the following features:

Comparision with Terminfo

This library uses the terminfo database for the terminal type given by $TERM as a first attempt to convert raw incoming bytes into symbolic keypress events. If this translation fails, and the terminal type is known to be one that uses xterm's generic CSI scheme for representing modified keypresses (e.g. xterm), then the sequence is interpreted according to xterm's rules. Finally, if all of these fail, the raw bytes will be presented as they are.

Special handling for screen is made, because of the way screen will translate some keypresses that it recognises, but passes on everything else verbatim. The xterm rules will also apply in this case, to cope with the case where screen is being driven by an xterm-like terminal, ensuring all the modified keypresses can still be interpreted.


Download source in tarball from:

The primary revision control repository is a Bazaar branch at http://bazaar.leonerd.org.uk/c/libtermkey/.

For an overview of the API, see here.

Online versions of the manpages are available in HTML form.

Language Bindings

This is a C library, but the following bindings exist for other languages.