charmbracelet / bubbletea

A powerful little TUI framework 🏗
MIT License
28.21k stars 817 forks source link

ctrl+<number> not captured #1207

Open jonas-grgt opened 1 month ago

jonas-grgt commented 1 month ago

When pressing ctrl+ only the number is received in the Update method.

To Reproduce

func (t *Model) Update(msg tea.Msg) {
    switch msg := msg.(type) {
    case tea.KeyMsg:
        if s := msg.String(); s == "ctrl+1" {

When pressing Ctrl+1 and evaluating msg.String() it returns "1"

Expected behavior When pressing Ctrl+1 and evaluating msg.String() it returns "ctrl+1"

semihbkgr commented 3 weeks ago

To my understanding, the behavior you're seeing with Ctrl+1 is because the terminal only sends the character 1 without a distinct representation for the Ctrl modifier, as numeric key combinations do not generate unique key events like some control characters do.

jonas-grgt commented 14 hours ago

@semihbkgr thanks for point this out I wasn't aware of this. So basically all Ctrl / Alt / Meta + number combinations can't be used?