mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-01-11 14:38:10 +03:00
key.Matches now accepts multiple binding arguments
This commit is contained in:
parent
0f500d5e59
commit
8d3cfdf380
12
key/key.go
12
key/key.go
@ -128,11 +128,13 @@ type Help struct {
|
||||
Desc string
|
||||
}
|
||||
|
||||
// Matches checks if the given KeyMsg matches a given binding.
|
||||
func Matches(k tea.KeyMsg, b Binding) bool {
|
||||
for _, v := range b.keys {
|
||||
if k.String() == v && b.Enabled() {
|
||||
return true
|
||||
// Matches checks if the given KeyMsg matches the given bindings.
|
||||
func Matches(k tea.KeyMsg, b ...Binding) bool {
|
||||
for _, binding := range b {
|
||||
for _, v := range binding.keys {
|
||||
if k.String() == v && binding.Enabled() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
Loading…
Reference in New Issue
Block a user