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,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