1616 * - X → B button
1717 * - Enter → Start
1818 * - Space → Select
19- * - Ctrl+S → Save state (via callback)
19+ * - P → Save state (via callback)
2020 * - Ctrl+C → Exit emulation
2121 *
2222 * Note: Non-blocking keyboard input in PHP CLI is limited.
@@ -31,8 +31,8 @@ final class CliInput implements InputInterface
3131 /** Control character for Ctrl+C (ASCII 3) */
3232 private const CTRL_C = "\x03" ;
3333
34- /** Control character for Ctrl+S (ASCII 19) */
35- private const CTRL_S = "\x13 " ;
34+ /** Character for save state trigger */
35+ private const SAVE_KEY = "p " ;
3636
3737 /** @var array<string, Button> Keyboard key to button mapping */
3838 private const KEY_MAP = [
@@ -88,9 +88,9 @@ public function __construct()
8888 }
8989
9090 /**
91- * Set callback to invoke when Ctrl+S is pressed.
91+ * Set callback to invoke when P key is pressed.
9292 *
93- * @param callable $callback Function to call when user presses Ctrl+S for save
93+ * @param callable $callback Function to call when user presses P for save
9494 */
9595 public function onSave (callable $ callback ): void
9696 {
@@ -219,8 +219,8 @@ private function parseInput(string $input): void
219219 exit (0 );
220220 }
221221
222- // Check for Ctrl+S (in raw mode, this comes through as ASCII 19 )
223- if (str_contains ($ input , self ::CTRL_S )) {
222+ // Check for P key (save state trigger )
223+ if (str_contains (strtolower ( $ input) , self ::SAVE_KEY )) {
224224 if ($ this ->onSaveCallback !== null ) {
225225 ($ this ->onSaveCallback )();
226226 }
0 commit comments