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)519312MITPHPPHP &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 4w ago

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

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 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community13

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

3768d 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/http-kernel

Provides a structured process for converting a Request into a Response

8.1k886.6M9.4k](/packages/symfony-http-kernel)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k257.3M12.2k](/packages/symfony-framework-bundle)[drush/drush

Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

2.4k61.7M828](/packages/drush-drush)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k18.3M414](/packages/easycorp-easyadmin-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k190.0M2.5k](/packages/symfony-security-bundle)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k39.6k](/packages/matomo-matomo)

PHPackages © 2026

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