[php-src] Issue #12939: Capture keypresses on Windows

From: Date: Tue, 12 Dec 2023 02:40:08 +0000
Subject: [php-src] Issue #12939: Capture keypresses on Windows
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246040@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12939 Author: terremoth ### Description Some tutorials and packages show it is possible to capture and handle keypresses on terminals, but only available on *nix systems The example below shows a commonly see implementation. ```php <?php $stdin = fopen('php://stdin', 'r'); stream_set_blocking($stdin, 0); while (1) { $keypress = fgets($stdin); if ($keypress) { echo 'Key pressed: ' . $keypress . PHP_EOL; } } ``` But that does not work on Windows. The intention is to capture a single keypress, of course, without typing enter. This would make possible things like terminal games and many command line apps, working for any O.S. This was discussed in the past here: https://bugs.php.net/bug.php?id=34972 ![image](https://github.com/php/php-src/assets/11032344/7eb38e46-6337-4131-b4e1-736b48fc40d8) CMB gave some hope this would be implemented, and so, not a bug at all.

« previous php.bugs (#246040) next »