Copy link to clipboard
Copied
Hello,
I am trying to create an on-screen keyboard for a touch-screen kiosk. Does anyone know how to send a keyboard event to a text input component from a button click event? For example, the user will push the on-screen buttons to enter their name, press tab to go to the next field, and so on.
I believe that I somehow need to use dispatchEvent but have not been able to get it to work. For example, pressing the on-screen A keyboard button will fire a CLICK event and call a handler to place an A in the currently focused text input component. The handler needs to be able to dispatch a keyboard event (with the correct keycode) to that text input field and that is where I am stuck.
Is this possible or am I on the wrong track?
Thank you in advance for any help or ideas.
Copy link to clipboard
Copied
You cannot force mouse or keyboard events - they HAVE TO come from mouse or keyboard.
In your case, since touch screen invokes MouseEvent - you, perhaps need to write your own code that will fire events from keyboard UI (not keyboard itself) and detect what "key" was clicked. It is similar to regular button functionality.
Copy link to clipboard
Copied
Are you positive that it is impossible to emulate a keyboard press?
'Cause I'm facing a quite difficult situation. I must read the mouse movement in X. Depending if X is positive or negative, it should dispatch and event saying that the left or right arrow have been pressed. Ain't there no other way to fake a key press?
Thank you.
Copy link to clipboard
Copied
you can create and dispatch any event using actionscript. you'll just need to assign appropriate event properties if you expect to use those properties in a listener function.
Copy link to clipboard
Copied
I actually just managed to make a simple script todo what I wanted. I little try&error, but it turned out allright:D
But thanks for the answer kglad.
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
That's not true. I simulate Mouse Events via other function all of the time!