From 97bbcdd5fb66d33df7986fe2106ec946d2d93662 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Sat, 11 Jan 2020 11:15:01 -0500 Subject: [PATCH] Catch Ctrl+C --- example/main.go | 2 ++ key.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/example/main.go b/example/main.go index 2601d7f..c0d0cfb 100644 --- a/example/main.go +++ b/example/main.go @@ -40,6 +40,8 @@ func update(msg tea.Msg, model tea.Model) (tea.Model, tea.Cmd) { case "q": fallthrough case "esc": + fallthrough + case "ctrl+c": return m, tea.Quit } diff --git a/key.go b/key.go index c16b30c..9e35bf4 100644 --- a/key.go +++ b/key.go @@ -11,11 +11,13 @@ type KeyPressMsg string // Control keys const ( + keyETX = 3 // ctrl+c keyESC = 27 keyUS = 31 ) var controlKeyNames = map[int]string{ + keyETX: "ctrl+c", keyESC: "esc", keyUS: "us", }