Replies: 1 comment
-
Is is necessary to trigger the behavior through keystrokes? Without knowing more about your use case I would suggest calling the logic you want triggered directly without going through keystrokes. import { bindKeyCombo } from '@rwh/keystrokes'
function doThing() {
// do thing here
}
buttonEl.addEventListener('click', doThing)
bindKeyCombo('a + b', doThing) If you need to interact with the event objects from either of these you could use a few wrapper functions. import { bindKeyCombo } from '@rwh/keystrokes'
function doThing() {
// do thing here
}
function handleClick(e) {
// do something with click event
doThing()
}
function handleKeyCombo(e) {
// do something with keystrokes key combo press event
doThing()
}
buttonEl.addEventListener('click', handleClick)
bindKeyCombo('a + b', doThing) Using keystrokes to dispatch the call would just be extra overhead given that you should just be able to call your function. Would this resolve your problem? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to forcibly trigger key events registered with bindkey or bindkeyCombo?
I want the user to act as if they entered a key event when clicking on a button component or the like.
Beta Was this translation helpful? Give feedback.
All reactions