Skip to main content
Participant
March 19, 2010
Question

dispatchEvent to send keyboard events (AS3)?

  • March 19, 2010
  • 1 reply
  • 6281 views

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.

This topic has been closed for replies.

1 reply

Inspiring
March 19, 2010

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.

Participating Frequently
April 15, 2010

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.

kglad
Community Expert
Community Expert
April 15, 2010

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.