Also use arrow keys in example

This commit is contained in:
Christian Rocha
2020-01-10 23:12:25 -05:00
parent bee32ca733
commit c7d28354f7
2 changed files with 18 additions and 4 deletions

View File

@@ -20,12 +20,16 @@ func update(msg tea.Msg, model tea.Model) (tea.Model, tea.Cmd) {
switch msg {
case "j":
fallthrough
case "down":
m += 1
if m > 3 {
m = 3
}
case "k":
fallthrough
case "up":
m -= 1
if m < 0 {
m = 0
@@ -52,7 +56,7 @@ func view(model tea.Model) string {
)
return fmt.Sprintf(
"What to do today?\n\n%s.\n\n(press j/k to select or q to quit)",
"What to do today?\n\n%s\n\n(press j/k or up/down to select, q to quit)",
choices,
)
}