File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -17,14 +17,21 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
17
17
case tea.KeyboardEnhancementsMsg :
18
18
return m , tea .Printf ("Keyboard enhancements enabled! ReleaseKeys: %v\n " , msg .SupportsKeyReleases ())
19
19
case tea.KeyMsg :
20
+ key := msg .Key ()
20
21
switch msg := msg .(type ) {
21
22
case tea.KeyPressMsg :
22
23
switch msg .String () {
23
24
case "ctrl+c" :
24
25
return m , tea .Quit
25
26
}
26
27
}
27
- return m , tea .Printf ("You pressed: %s (%T)\n " , msg .String (), msg )
28
+ format := "(%T) You pressed: %s"
29
+ args := []any {msg , msg .String ()}
30
+ if len (key .Text ) > 0 {
31
+ format += " (text: %q)"
32
+ args = append (args , key .Text )
33
+ }
34
+ return m , tea .Printf (format , args ... )
28
35
}
29
36
return m , nil
30
37
}
@@ -34,7 +41,7 @@ func (m model) View() string {
34
41
}
35
42
36
43
func main () {
37
- p := tea .NewProgram (model {}, tea .WithKeyboardEnhancements (tea .WithKeyReleases ))
44
+ p := tea .NewProgram (model {}, tea .WithKeyboardEnhancements (tea .WithKeyReleases , tea . WithUniformKeyLayout ))
38
45
if _ , err := p .Run (); err != nil {
39
46
log .Printf ("Error running program: %v" , err )
40
47
}
You can’t perform that action at this time.
0 commit comments