From 692322b84c8fd1f931304421a8f7839705d6e0c7 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Mon, 17 Feb 2020 21:46:29 -0500 Subject: [PATCH] Shift+tab cycles backwards over fields --- examples/inputs/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/inputs/main.go b/examples/inputs/main.go index e27498c..de9289c 100644 --- a/examples/inputs/main.go +++ b/examples/inputs/main.go @@ -47,10 +47,15 @@ func update(msg tea.Msg, model tea.Model) (tea.Model, tea.Cmd) { case tea.KeyMsg: switch msg.String() { + case "ctrl+c": return m, tea.Quit + + // Cycle between inputs case "tab": fallthrough + case "esc": // note: shift+tab sends an escape + fallthrough case "enter": fallthrough case "up": @@ -61,7 +66,7 @@ func update(msg tea.Msg, model tea.Model) (tea.Model, tea.Cmd) { m.emailInput, } - if msg.String() == "up" { + if msg.String() == "up" || msg.String() == "esc" { m.index-- } else { m.index++ @@ -85,6 +90,7 @@ func update(msg tea.Msg, model tea.Model) (tea.Model, tea.Cmd) { m.emailInput = inputs[1] return m, nil + default: m.nameInput, _ = input.Update(msg, m.nameInput) m.emailInput, _ = input.Update(msg, m.emailInput)