mirror of
https://github.com/taigrr/bubbletea.git
synced 2026-04-02 02:59:09 -07:00
Improve examples in docs
This commit is contained in:
17
key.go
17
key.go
@@ -11,19 +11,28 @@ import (
|
||||
// the program's update function. There are a couple general patterns you could
|
||||
// use to check for keypresses:
|
||||
//
|
||||
// // Switch on the type (safer)
|
||||
// switch msg := msg.(type) {
|
||||
// case KeyMsg:
|
||||
// switch msg.Type {
|
||||
// case KeyEnter:
|
||||
// fmt.Println("you pressed enter!")
|
||||
// case KeyEnter:
|
||||
// fmt.Println("you pressed enter!")
|
||||
// case KeyRune:
|
||||
// switch msg.Rune {
|
||||
// case 'a':
|
||||
// fmt.Println("you pressed a!")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Switch on the string representation of the key (shorter)
|
||||
// switch msg := msg.(type) {
|
||||
// case KeyMsg:
|
||||
// switch msg.String() {
|
||||
// case "enter":
|
||||
// fmt.Println("you pressed enter!")
|
||||
// case "enter":
|
||||
// fmt.Println("you pressed enter!")
|
||||
// case "a':
|
||||
// fmt.Println("you pressed a!")
|
||||
// }
|
||||
// }
|
||||
type KeyMsg Key
|
||||
|
||||
Reference in New Issue
Block a user