key.Matches now accepts multiple binding arguments

This commit is contained in:
Christian Rocha 2021-12-20 18:17:08 -05:00
parent 0f500d5e59
commit 8d3cfdf380

View File

@ -128,12 +128,14 @@ type Help struct {
Desc string Desc string
} }
// Matches checks if the given KeyMsg matches a given binding. // Matches checks if the given KeyMsg matches the given bindings.
func Matches(k tea.KeyMsg, b Binding) bool { func Matches(k tea.KeyMsg, b ...Binding) bool {
for _, v := range b.keys { for _, binding := range b {
if k.String() == v && b.Enabled() { for _, v := range binding.keys {
if k.String() == v && binding.Enabled() {
return true return true
} }
} }
}
return false return false
} }