@@ -168,20 +168,75 @@ type View struct {
168168 // [MouseModeNone], [MouseModeCellMotion], or [MouseModeAllMotion].
169169 MouseMode MouseMode
170170
171- // DisableKeyEnhancements disables all key enhancements for this view.
172- DisableKeyEnhancements bool
173-
174- // KeyReleases enables support for reporting key release events. This is
175- // useful for terminals that support the Kitty keyboard protocol "Report
176- // event types" progressive enhancement feature.
177- KeyReleases bool
178-
179- // UniformKeyLayout enables support for reporting key events as though they
180- // were on a PC-101 layout. This is useful for uniform key event reporting
181- // across different keyboard layouts. This is equivalent to the Kitty
182- // keyboard protocol "Report alternate keys" and "Report all keys as escape
183- // codes" progressive enhancement features.
184- UniformKeyLayout bool
171+ // KeyboardEnhancements describes what keyboard enhancement features Bubble
172+ // Tea should request from the terminal.
173+ //
174+ // Bubble Tea supports requesting the following keyboard enhancement features:
175+ // - ReportEventTypes: requests the terminal to report key repeat and
176+ // release events.
177+ //
178+ // If the terminal supports any of these features, your program will
179+ // receive a [KeyboardEnhancementsMsg] that indicates which features are
180+ // available.
181+ KeyboardEnhancements KeyboardEnhancements
182+ }
183+
184+ // KeyboardEnhancements describes the requested keyboard enhancement features.
185+ // If the terminal supports any of them, it will respond with a
186+ // [KeyboardEnhancementsMsg] that indicates which features are supported.
187+
188+ // KeyboardEnhancements defines different keyboard enhancement features that
189+ // can be requested from the terminal.
190+
191+ // KeyboardEnhancements defines different keyboard enhancement features that
192+ // can be requested from the terminal.
193+ //
194+ // By default, Bubble Tea requests basic key disambiguation features from the
195+ // terminal. If the terminal supports keyboard enhancements, or any of its
196+ // additional features, it will respond with a [KeyboardEnhancementsMsg] that
197+ // indicates which features are supported.
198+ //
199+ // Example:
200+ //
201+ // ```go
202+ // func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
203+ // switch msg := msg.(type) {
204+ // case tea.KeyboardEnhancementsMsg:
205+ // // We have basic key disambiguation support.
206+ // // We can handle "shift+enter", "ctrl+i", etc.
207+ // m.keyboardEnhancements = msg
208+ // if msg.ReportEventTypes {
209+ // // Even better! We can now handle key repeat and release events.
210+ // }
211+ // case tea.KeyPressMsg:
212+ // switch msg.String() {
213+ // case "shift+enter":
214+ // // Handle shift+enter
215+ // // This would not be possible without keyboard enhancements.
216+ // case "ctrl+j":
217+ // // Handle ctrl+j
218+ // }
219+ // case tea.KeyReleaseMsg:
220+ // // Whoa! A key was released!
221+ // }
222+ //
223+ // return m, nil
224+ // }
225+ //
226+ // func (m model) View() tea.View {
227+ // v := tea.NewView("Press some keys!")
228+ // // Request reporting key repeat and release events.
229+ // v.KeyboardEnhancements.ReportEventTypes = true
230+ // return v
231+ // }
232+ // ```
233+ type KeyboardEnhancements struct {
234+ // ReportEventTypes requests the terminal to report key repeat and release
235+ // events.
236+ // If supported, your program will receive [KeyReleaseMsg]s and
237+ // [KeyPressMsg] with the [Key.IsRepeat] field set indicating that this is
238+ // a it's part of a key repeat sequence.
239+ ReportEventTypes bool
185240}
186241
187242// SetContent sets the content of the view to the value.
0 commit comments