Skip to content

Commit

Permalink
key.Matches now accepts multiple arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Dec 20, 2021
1 parent 0ac5ecd commit 91b06fa
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions key/key.go
Expand Up @@ -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
Expand Down

0 comments on commit 91b06fa

Please sign in to comment.