-
Notifications
You must be signed in to change notification settings - Fork 321
Description
Describe the bug
I can't find a way to simulate the user holding shift and pressing down.
At fist I tried to implement this manually in the script, but nothing I tried worked. This is everything I tried and got compile errors:
Shift Down
Shift Down 1
Shift+Down
Key "shift" "down"
Key "shift+down"
I then tried to use vhs record
to create what I needed. Performing a shift down in a recording session produces the following which does nothing when trying to record a demo using the script.
Type "[1;2B"
Setup
Please complete the following information along with version numbers, if applicable.
- OS: macOS
- Shell: zsh
- Terminal Emulator: iterm
- Terminal Multiplexer: tmux
To Reproduce
Use the min example I put in the source code and run this vhs demo tape:
Output demo.gif
Set Framerate 10
Set Shell zsh
Set FontSize 24
Set Width 1200
Set Height 600
Type "go run main.go"
Sleep 1s
Enter
Sleep 2s
# Test shift down from vhs record:
Type "[1;2B"
Type "[1;2B"
Type "[1;2B"
Sleep 5s
Source Code
package main
import (
"fmt"
"log"
"os"
tea "github.com/charmbracelet/bubbletea"
)
type model struct {
events []string
}
func (m model) Init() tea.Cmd {
return nil
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case "q", "ctrl+c", "esc":
return m, tea.Quit
case "shift+down":
m.events = append(m.events, "Got shift+down!")
default:
m.events = append(m.events, fmt.Sprintf("Got key: %q", msg.String()))
}
// Keep only last 10 events
if len(m.events) > 10 {
m.events = m.events[len(m.events)-10:]
}
}
return m, nil
}
func (m model) View() string {
s := "Shift+Down Key Event Test\n"
s += "========================\n\n"
s += "Press Shift+Down to test the key event\n"
s += "Press 'q' or 'esc' to quit\n\n"
s += "Recent events:\n"
for _, event := range m.events {
s += " " + event + "\n"
}
return s
}
func main() {
p := tea.NewProgram(model{events: []string{}})
if _, err := p.Run(); err != nil {
log.Fatal(err)
os.Exit(1)
}
}
Expected behavior
Got shift+down!
should be printed three times, but instead every key in the Type statement is sent.
Screenshots
Add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.