PHPackages                             ignasbernotas/phkey - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. ignasbernotas/phkey

ActiveLibrary[CLI &amp; Console](/categories/cli)

ignasbernotas/phkey
===================

A PHP based API to capture key presses from the terminal.

0.1.1(10y ago)5193↓100%11MITPHPPHP &gt;=5.5.9

Since Feb 2Pushed 3y ago2 watchersCompare

[ Source](https://github.com/ignasbernotas/phkey)[ Packagist](https://packagist.org/packages/ignasbernotas/phkey)[ Docs](https://iber.lt)[ RSS](/packages/ignasbernotas-phkey/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (1)

PHKey
=====

[](#phkey)

PHP based command line key listener.

[![Example](https://camo.githubusercontent.com/e786e0f0cd65d199a4330dda77602bbda20776e07f6f790eb0b4fd5c9cbe1fe4/68747470733a2f2f696265722e6c742f6173736574732f696d616765732f70726f6a656374732f70686b65792e676966)](https://camo.githubusercontent.com/e786e0f0cd65d199a4330dda77602bbda20776e07f6f790eb0b4fd5c9cbe1fe4/68747470733a2f2f696265722e6c742f6173736574732f696d616765732f70726f6a656374732f70686b65792e676966)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#php-based-command-line-key-listener)

This library provides an API to capture keys from the terminal. It currently supports latin-basic range of characters such as direction keys, function keys (F\*), enter, space, insert, delete, backspace, escape, a-z, etc.

Installation
------------

[](#installation)

You can either download this library as a zip, or simply install it via composer:

```
composer require ignasbernotas/phkey

```

Limitations
-----------

[](#limitations)

This package only works on UNIX/Linux based systems since the Windows PHP version doesn't not support the readline extension.

Example
-------

[](#example)

##### Capture all keys

[](#capture-all-keys)

```
use \Iber\Phkey\Events\KeyPressEvent;
use \Iber\Phkey\Environment\Detector;

$detect = new Detector();
$listener = $detect->getListenerInstance();

$eventDispatcher = $listener->getEventDispatcher();

$eventDispatcher->addListener('key:press', function(KeyPressEvent $event) {
    echo $event->getKey(), PHP_EOL;
});

$eventDispatcher->addListener('key:enter', function(KeyPressEvent $event) use ($eventDispatcher) {
    echo 'Key "', $event->getKey(), '" was pressed. Quitting listener.', PHP_EOL;

    // notify the listener to stop
    $eventDispatcher->dispatch('key:stop:listening');
});

$listener->start();
```

License
-------

[](#license)

Licensed under MIT.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~71 days

Total

2

Last Release

3677d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9eaa43c7213e1c9803bda2818792373a21b3078a01631d0ffe04410de64e26ef?d=identicon)[ignasbernotas](/maintainers/ignasbernotas)

---

Top Contributors

[![iberflow](https://avatars.githubusercontent.com/u/402965?v=4)](https://github.com/iberflow "iberflow (6 commits)")

---

Tags

clikeyskeyboardkey press

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ignasbernotas-phkey/health.svg)

```
[![Health](https://phpackages.com/badges/ignasbernotas-phkey/health.svg)](https://phpackages.com/packages/ignasbernotas-phkey)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B11.2k](/packages/symfony-console)[cilex/cilex

The PHP micro-framework for Command line tools based on the Symfony2 Components

6183.2M14](/packages/cilex-cilex)[n98/magerun

Tools for managing Magento projects and installations

1.4k264.7k7](/packages/n98-magerun)[n98/magerun2

Tools for managing Magento projects and installations

928244.3k6](/packages/n98-magerun2)[laminas/laminas-cli

Command-line interface for Laminas projects

563.7M54](/packages/laminas-laminas-cli)[duncan3dc/console

Create command line php applications using symfony/console

17263.4k1](/packages/duncan3dc-console)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
