Skip to content

Allow key.Matches to accept multiple binding arguments#84

Merged
meowgorithm merged 1 commit intomasterfrom
key-matches-multiarg
Jan 10, 2022
Merged

Allow key.Matches to accept multiple binding arguments#84
meowgorithm merged 1 commit intomasterfrom
key-matches-multiarg

Conversation

@meowgorithm
Copy link
Copy Markdown
Member

@meowgorithm meowgorithm commented Dec 20, 2021

key.Binding currently allows you to bind against multiple keys:

binding := key.Binding(key.WithKeys("q", "ctrl+c"))

However, sometimes you may also want to match on multiple bindings at once:

left := key.Binding(key.WithKeys("h", "left"))
right := key.Binding(key.WithKeys("l", "right"))

case key.Matches(msg, left), key.Matches(msg, right):

This update expands key.Matches to accept multiple arguments so you can condense the above case statement to:

case key.Matches(msg, left, right):

@meowgorithm meowgorithm changed the title key.Matches now accepts multiple arguments Allow key.Matches to accept multiple binding arguments Dec 20, 2021
@meowgorithm meowgorithm merged commit 8d3cfdf into master Jan 10, 2022
@meowgorithm meowgorithm deleted the key-matches-multiarg branch January 10, 2022 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant