Open
Description
Describe the bug
It looks as though the tea.KeyReleaseMsg
s are not being handled correctly on macOS. In some instances [ghostty w/o tmux] it is working as expected. But in a few tested instances [ghostty w. tmux] [macos stock terminal w or w/o tmux]] I am seeing no release messages making it through
Setup
Setup One
- OS [macOS 15.3.1 ]
- Shell [zsh]
- Terminal Emulator [ghostty]
- Terminal Multiplexer [tmux]
Setup Two
- OS [macOS 15.3.1 ]
- Shell [zsh]
- Terminal Emulator [macos stock terminal]
- Terminal Multiplexer [tmux or without]
To Reproduce
Steps to reproduce the behavior:
- Build the code
- Run the application in different environments
- See the lack of key release messages
Source Code
package main
import (
"fmt"
"os"
tea "github.com/charmbracelet/bubbletea/v2"
)
type model struct{}
func (m model) Init() tea.Cmd {
// Nothing needs to be initialized
return nil
}
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
// I'm a key press or release message
switch key := msg.(type) {
case tea.KeyReleaseMsg:
// I'm a key release message ;)
return m, tea.Printf("Key released: %s", key)
case tea.KeyPressMsg:
switch key.Mod {
case tea.ModCtrl:
switch key.Code {
case 'c':
return m, tea.Quit
}
}
// I'm a key press message
return m, tea.Printf("You pressed %s", key)
}
}
return m, nil
}
func (m model) View() string {
return "Press keys..."
}
func main() {
p := tea.NewProgram(model{}, tea.WithKeyboardEnhancements(
tea.WithKeyReleases, // Do we want to listen to key releases?
tea.WithUniformKeyLayout,
))
if _, err := p.Run(); err != nil {
fmt.Printf("Alas, there's been an error: %v", err)
os.Exit(1)
}
}
Expected behavior
Key release messages correctly fire across macOS terminals.
Screenshots
Showing [ghostty w/ tmux] and then [ghostty w/o tmux]
Screen.Recording.2025-04-11.at.12.33.46.AM.mov
Showing [terminal w/ tmux] and then [terminal w/o tmux]
Screen.Recording.2025-04-11.at.12.35.48.AM.mov
Metadata
Metadata
Assignees
Labels
No labels