charmbracelet / charmbracelet/bubbletea
Cannot detect Ctrl + Space keypress in Windows
- Dominant language
- Go
- Stars
- 44.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Cannot detect Ctrl + Space keypress in Windows, instead it looks identical to pressing "Space".
**Setup**
- OS - Windows 11
- Shell - Windows Powershell
- Terminal Emulator - No emulator. Plain windows powershell
- Terminal Multiplexer - None
**To Reproduce**
Steps to reproduce the behavior:
1. Execute the source code below
2. Press Ctrl + Space
3. Read the prog.log file for logs
**Source Code**
Code
```go
package main
import (
"fmt"
"log"
"os"
tea "github.com/charmbracelet/bubbletea"
)
type model struct {
header string
content string
keycnt int
// Add any fields you need for your model
}
func (m model) Init() tea.Cmd {
return nil
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.keycnt++
m.content = fmt.Sprintf("\n(Key %d)", m.keycnt)
switch msg := msg.(type) {
case tea.KeyMsg:
m.content += fmt.Sprintf("msg = %v, typestr = %v, runes = %v, type = %d, paste=%v, alt=%v",
msg, msg.Type.String(), msg.Runes, msg.Type, msg.Paste, msg.Alt)
log.Println(m.content)
if msg.String() == "q" {
return m, tea.Quit
}
}
return m, nil
}
func (m model) View() string {
return fmt.Sprintf("%s\n%s", m.header, m.content)
}
func main() {
f,err := os.OpenFile("prog.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err!= nil {
panic(err)
}
log.SetOutput(f)
p := tea.NewProgram(model{header: "Press Enter or Ctrl + M\n"})
if _,err:=p.Run(); err != nil {
fmt.Printf("Error starting program: %v", err)
}
}
```
**Expected behavior**
I should see Ctrl+space, or something different than just "space"
**Screenshots**
Space produces:
Ctrl+Space produces the same:
Contributor guide
Research direction
Start with the supplied Go reproduction in plain Windows PowerShell and inspect the tea.KeyMsg logging for Space versus Ctrl+Space. Trace the input path relevant to this environment and verify whether the two keypresses can be represented distinctly; done means the behavior is distinguishable or the environment limitation is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100