Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import flash.ui.Keyboard;
  2. import flash.events.KeyboardEvent;
  3. import flash.events.FocusEvent;
  4.  
  5. inputText.addEventListener(FocusEvent.FOCUS_IN,textInputHandler);
  6. inputText.addEventListener(FocusEvent.FOCUS_OUT,textInputHandlerOut);
  7.  
  8. function textInputHandler (event:FocusEvent):void {
  9.     stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
  10.     output_txt.text = "Behold!";
  11. }
  12.  
  13. function textInputHandlerOut (event:FocusEvent):void {
  14.     stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
  15.     output_txt.text = "Silence!";
  16. }
  17.  
  18. function keyDownHandler (event:KeyboardEvent):void {
  19.         if( event.charCode == 13 ){
  20.       checkInput();
  21.     }
  22. }
  23.  
  24.  
  25. function keyHit(evt:KeyboardEvent):void {
  26.    trace("key pressed " +evt.keyCode);
  27.    if (evt.keyCode == 13) {
  28.                trace ("Okidoki");
  29.    }
  30. }
  31.  
  32. function checkInput () {
  33.         output_txt.text = "Pressed Enter";
  34.         trace("Pressed Enter");
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement