Skip navigation
Hugga_Tree
Currently Being Moderated

dispatchEvent to send keyboard events (AS3)?

Mar 19, 2010 7:08 AM

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.

 
Replies
  • Currently Being Moderated
    Mar 19, 2010 7:32 AM   in reply to Hugga_Tree

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 15, 2010 11:44 AM   in reply to Andrei1

    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.

     
    |
    Mark as:
  • kglad
    72,261 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 15, 2010 12:33 PM   in reply to Animaleante

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 15, 2010 12:47 PM   in reply to kglad

    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.

     
    |
    Mark as:
  • kglad
    72,261 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 15, 2010 1:10 PM   in reply to Animaleante

    you're welcome.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 10, 2012 5:34 PM   in reply to Andrei1

    That's not true. I simulate Mouse Events via other function all of the time!

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points