laravel / prompts

Beautiful and user-friendly forms for your command-line PHP applications.
https://laravel.com/docs/prompts
MIT License
533 stars 94 forks source link

Add support for alternative arrow keys #40

Closed jessarcher closed 1 year ago

jessarcher commented 1 year ago

This PR adds support for alternative arrow key codes used in some scenarios.

Specifically, something called "Single Shift Three" (SS3). This Stack Exchange post does a pretty good job of explaining it, but essentially there are two escape sequences that can represent the directional keys.

Example from infocmp:

cuu1=\E[A
kcuu1=\EOA

And man termcap:

   cursor_up              cuu1                    up               up one line
   key_up                 kcuu1                   ku               up-arrow key

I'm not entirely sure what common scenarios would cause \EOA to be sent, but at least one user has reported this on 1 of 3 Macs with iTerm, and they've confirmed this fix.

Coming up with new names was a bit tricky, especially without renaming anything existing :woman_shrugging:

Fixes #31