forked from Mirrors/bubbletea
Catch Ctrl+C
This commit is contained in:
parent
d9cf7d1477
commit
97bbcdd5fb
|
@ -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
2
key.go
|
@ -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",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue