Closed ku1ik closed 1 week ago
LGTM. This is awesome - and I'm excited to use it. Since folks approaching the project might wonder how you chose the notation, can you add a sentence (and maybe a link) saying where we copied the notation from (tmux
right)?
This PR brings greatly improved keyboard input support, with the new
sendKeys
command (inspired by tmux).From the updated README:
sendKeys
command allows sending keys to a process running in the virtual terminal as if the keys were pressed on a keyboard.Each element of the
keys
array can be either a key name or an arbitrary text. If a key is not matched by any supported key name then the text is sent to the process as is, i.e. like when using theinput
command.This command doesn't produce any output on stdout.
The following key specifications are currently supported:
Enter
Space
Escape
or^[
orC-[
Tab
Left
- left arrow keyRight
- right arrow keyUp
- up arrow keyDown
- down arrow keyHome
End
PageUp
PageDown
F1
toF12
Modifier keys are supported by prepending a key with one of the prefixes:
^
- control - e.g.^c
means Ctrl + CC-
- control - e.g.C-c
means Ctrl + CS-
- shift - e.g.S-F6
means Shift + F6A-
- alt/option - e.g.A-Home
means Alt + HomeModifiers can be combined (for arrow keys only at the moment), so combinations such as
S-A-Up
orC-S-Left
are possible.C-
control modifier notation can be used with ASCII letters (both lower and upper case are supported) and most special key names. The caret control notation (^
) may only be used with ASCII letters, not with special keys.Shift modifier can be used with special key names only, such as
Left
,PageUp
etc. For text characters, instead of specifying e.g.S-a
just use upper caseA
.Alt modifier can be used with any Unicode character and most special key names.
I also updated the description of the existing
input
command, stating it's a more lower level, raw input mode.Thing to consider: use angle brackets for special keys, e.g.
<Enter>
instead ofEnter
. Key names are matched unambiguously already, thanks to thesendKeys
arg being an array, so technically using angle brackets wouldn't make it work any better. This would just look nicer (?) for us humans I guess. But not sure :)