Catch Ctrl+C

This commit is contained in:
Christian Rocha 2020-01-11 11:15:01 -05:00
parent d9cf7d1477
commit 97bbcdd5fb
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018
2 changed files with 4 additions and 0 deletions

View File

@ -40,6 +40,8 @@ func update(msg tea.Msg, model tea.Model) (tea.Model, tea.Cmd) {
case "q": case "q":
fallthrough fallthrough
case "esc": case "esc":
fallthrough
case "ctrl+c":
return m, tea.Quit return m, tea.Quit
} }

2
key.go
View File

@ -11,11 +11,13 @@ type KeyPressMsg string
// Control keys // Control keys
const ( const (
keyETX = 3 // ctrl+c
keyESC = 27 keyESC = 27
keyUS = 31 keyUS = 31
) )
var controlKeyNames = map[int]string{ var controlKeyNames = map[int]string{
keyETX: "ctrl+c",
keyESC: "esc", keyESC: "esc",
keyUS: "us", keyUS: "us",
} }