@@ -44,17 +44,10 @@ public function __construct(ReadableStreamInterface $input, WritableStreamInterf
4444
4545 $ that = $ this ;
4646 $ codes = array (
47- // The user confirms input with enter key which should usually
48- // generate a NL (`\n`) character. Common terminals also seem to
49- // accept a CR (`\r`) character in place and handle this just like a
50- // NL. Similarly `ext-readline` uses different `icrnl` and `igncr`
51- // TTY settings on some platforms, so we also accept both here.
52- "\n" => 'onKeyEnter ' , // ^J
53- "\r" => 'onKeyEnter ' , // ^M
54-
55- "\x7f" => 'onKeyBackspace ' ,
56- "\t" => 'onKeyTab ' ,
57- "\x04" => 'handleEnd ' , // CTRL+D
47+ "\n" => 'onKeyEnter ' , // ^J
48+ "\x7f" => 'onKeyBackspace ' , // ^?
49+ "\t" => 'onKeyTab ' , // ^I
50+ "\x04" => 'handleEnd ' , // ^D
5851
5952 "\033[A " => 'onKeyUp ' ,
6053 "\033[B " => 'onKeyDown ' ,
@@ -69,6 +62,16 @@ public function __construct(ReadableStreamInterface $input, WritableStreamInterf
6962// "\033[20~" => 'onKeyF10',
7063 );
7164 $ decode = function ($ code ) use ($ codes , $ that ) {
65+ // The user confirms input with enter key which should usually
66+ // generate a NL (`\n`) character. Common terminals also seem to
67+ // accept a CR (`\r`) character in place and handle this just like a
68+ // NL. Similarly `ext-readline` uses different `icrnl` and `igncr`
69+ // TTY settings on some platforms, so we also accept CR as an alias
70+ // for NL here. This implies key binding for NL will also trigger.
71+ if ($ code === "\r" ) {
72+ $ code = "\n" ;
73+ }
74+
7275 if ($ that ->listeners ($ code )) {
7376 $ that ->emit ($ code , array ($ code ));
7477 return ;
0 commit comments