// Package keyprobe is a tiny `glint keys` diagnostic that shows exactly what // key events the terminal delivers — useful for discovering what Cmd+Arrow, // Alt+Arrow, and friends send so they can be bound. package keyprobe import ( "fmt" "strings" tea "github.com/charmbracelet/bubbletea" ) type model struct{ lines []string } func (m model) Init() tea.Cmd { return nil } func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { if k, ok := msg.(tea.KeyMsg); ok { if k.Type == tea.KeyCtrlC { return m, tea.Quit } m.lines = append(m.lines, fmt.Sprintf("String=%-12q Type=%-3d Alt=%-5v Runes=%q", k.String(), int(k.Type), k.Alt, string(k.Runes))) if len(m.lines) > 20 { m.lines = m.lines[len(m.lines)-20:] } } return m, nil } func (m model) View() string { return "glint key probe — press keys (Cmd+Arrows, Alt+Arrows, Cmd+Delete, …). Ctrl+C to quit.\n\n" + strings.Join(m.lines, "\n") + "\n" } // Run launches the probe. func Run() error { _, err := tea.NewProgram(model{}, tea.WithAltScreen()).Run() return err }