Open dailyraisin opened 6 years ago
Interesting! That sounds pretty simple to implement. Do you have a scenario that I could create locally to test against when I add this?
Hi, @dailyraisin @ten1seven I am interested in the same feature. I use React and here is my scenario:
onKeyDown
handler is called on a component A
component B
and focuses itonFocus
handler of component B
is called where it is checked if the whatInput.ask() === 'keyboard'
, we will get here false
window.addEventListener('keydown')
from what-input
lib is called and update a state to keyboard
but it's too late for me.It would be very useful to have access to function like setInput
, so I can call on initial onKeyDown
handler of component B
and update the state accordingly.
@ten1seven let me know what you think
Hi @sophieH29, I'm digging into this request. Are you push a specific input to what-input and trigger a doUpdate
? Something like this?
whatInput.setInput('keyboard');
Hi @ten1seven, I would rather say just to make current function setInput
public, so I will be able to call it onKeyDown event and update state, like
onKeyDown = (ev) => {
...
whatInput.setInput(ev)
...
}
@ten1seven do you plan to make this update to the library?
In cases where one wants to prevent default key events (e.g. stopping, preventDefault), it would be necessary to call
doUpdate('intent')
manually from the outside as whatInput listeners will not be reached.