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":
fallthrough
case "esc":
fallthrough
case "ctrl+c":
return m, tea.Quit
}

2
key.go
View File

@ -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",
}