Capturing keyboard events?

How is it possible to listen to keyboard events, as the depressed return key?  I understand the class ReturnKeyType does not yet work for the QNX InputText component, but even when it's that I'm not sure it will include keyboard events or if it will just be a Visual change to the BACKSPACE on the keyboard.

I intend using the class flash.text.TextField (for portability) instead of qnx.ui.text.InputText.  Currently, the keyboard will activate and disappear the flash.text.TextField receives or loses the focus.  However, these text fields are the fields of data entry, so I would listen to the back of the key on the keyboard so that I may as well save entered data and remove the keyboard of the screen - or perhaps more simply, just leave the text field to listen to when it loses focus to save the data and allow the keyboard to disappear.  But how do I activate either by pressing back on the keyboard?

Hey David,

You can achieve this by using a listener to listen to the keys on your input object as a textfield and response following which keys are pressed. in your case you would listen for the Enter key and perform your actions like taking the focus and the keyboard on the screen. You can use the program below as a reference as to how this can be done:

package
{
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.KeyboardEvent;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFieldType;
    import flash.ui.Keyboard;

    [SWF(width="1024",height="600",backgroundColor="#CCCCCC",frameRate="30")]
    public class TextFieldTest extends Sprite
    {

        private var myInput:TextField;

        public function TextFieldTest()
        {
            super();

            // support autoOrients
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;

            myInput = new TextField();
            myInput.width = 300;
            myInput.height = 50;
            myInput.type = TextFieldType.INPUT;

            /*
             * listen for what keys are being pressed and react with
             * onKeyDown function
            */
            myInput.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);

            addChild(myInput);

        }
        private function onKeyDown(e:KeyboardEvent):void
        {
            /*
             * You can listen for any key presses under the
             * flash.ui.Keyboard class. it has all the constants
             * such as .ENTER, .END, etc
            */
            if (e.keyCode == Keyboard.ENTER)
            {
                trace("You just entered");

                /*
                 * Steal focus away from the textfield object
                 * focus can be set to anywhere and the keyboard
                 * will disappear
                */

                stage.focus = null;

                /*
                 * Perform other actions such as saving data
                */
            }
        }

    }
}

hope that helps. Good luck!

Tags: BlackBerry Developers

Similar Questions

  • Keyboard event capture [CS6]

    Hello

    I need to capture a key event in InDesign. I tried using "keydown" event, but it gives the error: 'keydown' is not a recognized event type

    app.addEventListener ("keyDown", function(k){
             if(k.escKey)
               {
                 if(app.activeDocument && app.activeDocument.placeGuns.loaded)
                     app.activeDocument.placeGuns.abortPlaceGun();
               }
        })
    
    

    Can someone let me know what I'm doing wrong or how to capture this event.

    Thank you

    Mac

    Mac_06 wrote:

    Support of keyboard in the document-level event? How know what taken events are supported by a particular object?

    I don't think so.

    By saying "at the level of the Application" I meant that keyboard/mouse events are not implemented at all in the scope of the application script (in contrast with ScriptUI) model.

    Note: It's a misconception to think events like belonging or triggered by some specific objects in the DOM. In fact, objects can listen for events (through the addEventListener methods), and usually any object can listen to any event according to the method of capture and the phase of the event. During its spread, an event (instance) provides such as target and currentTarget properties that provide details on the context, but there is no real link between the event and an object specifier. The event is triggered by the subsystem.

    In CS5 and later we have six events, represented by the 'classes' following fields: DocumentEvent, MutationEvent, ImportExportEvent, PrintEvent, event (base class), IdleEvent. This is just a prototype API for all types of events which InDesign agree to make available in the DOM:

    AFTER_ACTIVATE  [Event]
    AFTER_ATTRIBUTE_CHANGED  [MutationEvent]
    AFTER_CLOSE  [DocumentEvent]
    AFTER_CLOSE  [Event]
    AFTER_CONTEXT_CHANGED  [Event]
    AFTER_DELETE  [Event]
    AFTER_EMBED  [Event]
    AFTER_EXPORT  [ImportExportEvent]
    AFTER_IMPORT  [ImportExportEvent]
    AFTER_INVOKE  [Event]
    AFTER_LINKS_CHANGED  [Event]
    AFTER_MOVE  [Event]
    AFTER_NEW  [DocumentEvent]
    AFTER_NEW  [Event]
    AFTER_OPEN  [DocumentEvent]
    AFTER_OPEN  [Event]
    AFTER_PLACE  [Event]
    AFTER_PRINT  [PrintEvent]
    AFTER_QUIT  [Event]
    AFTER_REVERT  [DocumentEvent]
    AFTER_SAVE  [DocumentEvent]
    AFTER_SAVE_AS  [DocumentEvent]
    AFTER_SAVE_A_COPY  [DocumentEvent]
    AFTER_SELECTION_ATTRIBUTE_CHANGED  [Event]
    AFTER_SELECTION_CHANGED  [Event]
    AFTER_UNEMBED  [Event]
    AFTER_UPDATE  [Event]
    
    BEFORE_CLOSE  [DocumentEvent]
    BEFORE_CLOSE  [Event]
    BEFORE_DEACTIVATE  [Event]
    BEFORE_DELETE  [Event]
    BEFORE_DISPLAY  [Event]
    BEFORE_EMBED  [Event]
    BEFORE_EXPORT  [ImportExportEvent]
    BEFORE_IMPORT  [ImportExportEvent]
    BEFORE_INVOKE  [Event]
    BEFORE_MOVE  [Event]
    BEFORE_NEW  [DocumentEvent]
    BEFORE_OPEN  [DocumentEvent]
    BEFORE_PLACE  [Event]
    BEFORE_PRINT  [PrintEvent]
    BEFORE_QUIT  [Event]
    BEFORE_REVERT  [DocumentEvent]
    BEFORE_SAVE  [DocumentEvent]
    BEFORE_SAVE_AS  [DocumentEvent]
    BEFORE_SAVE_A_COPY  [DocumentEvent]
    BEFORE_UNEMBED  [Event]
    BEFORE_UPDATE  [Event]
    
    FAILED_EXPORT  [ImportExportEvent]
    ON_IDLE  [IdleEvent]
    ON_INVOKE  [Event]
    

    I guess that this list may change in the future...

    @+

    Marc

  • Keyboard events can be captured by our plugins?

    My plugin runs through the paths of PDEPage and the elements, placing those surrounded by the classic rubberband rectangle in the Windows Clipboard. In short, it implements the copy half an installation "copy / paste".

    Sometimes, the user may choose to type Ctrl-A to select a maximum rectangle.

    Is this possible? How?

    TIA

    If you have a custom tool is active, your tool can register for keyboard events.

  • Sniff for PrintScreen. In Windows 8 blocked keyboard events, monitor what task is to the point.

    In God we trust.

    Good day, everyone.

    My application designed to block the screen capture. It is based on the events of keyboard hook.

    In Windows 8 my callback function is not called, when the monitor of the task is in short.

    I save my callback function with:

    lowLevelKybdHook_ = SetWindowsHookEx ( WH_KEYBOARD_LL, (HOOKPROC): MyCallbackFunction, hInstance, 0);

    It works perfectly in Windows 7 for all cases.

    Windows 8:

    -He works when the monitor of the task is not open.

    -It works, when Task Monitor is opened, not to the point.

    -It does NOT works when the monitor task in short, i.e. my callback function is not called when the task to monitor is the currently selected window.

    -Continue to work (to be called), when the monitor of the task is not to the point.

    I tried to use RegisterHotKey instead SetWindowsHookEx, it has the same effect.

    Any idea?

    Thank you in advance,

    Israel

    PS: I see the same effect with Microsoft Spy ++.
    Keyboard events are blocked, when Microsoft Spy ++ open and in focus.

    Hello Israel,

    Welcome to the Microsoft community.

    Your question of Windows is more complex than what is generally answered in the Microsoft Answers forum. It is better you post the same query in the Microsoft Developer Community. You can get more effective suggestions and adapted by experts familiar with this topic.

    You can also consult the following link:

    https://social.msdn.Microsoft.com/forums/en-us/4cda8492-df2e-4D6F-8eee-4b85c491a493/packet-sniffing?Forum=netfxnetcom

    Hope the helps of information. Let us know if you need help with Windows related issues. We will be happy to help you.

    Thank you

  • Keyboard event!

    Hello

    I want to create a keyboard event listener in a flex air application. When I try to launch the application it popup a message and says:

    TypeError: Error #1009: cannot access a property or method of a null object reference.
    hand / windowedapplication1_creationCompleteHandler () [F:\Flex Project\experiment\Capture keyboard Input\src\Main.mxml:19]
    hand / ___Main_WindowedApplication1_creationComplete () [F:\Flex Project\experiment\Capture keyboard Input\src\Main.mxml:4]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.core::UIComponent/dispatchEvent() [E:\dev\4.0.0\frameworks\projects\framework\src\mx\co re\UIComponent.as:12266]
    to mx.core::UIComponent / set initialized() [E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1577]
    at mx.managers::LayoutManager/doPhasedInstantiation() [E:\dev\4.0.0\frameworks\projects\frame work\src\mx\managers\LayoutManager.as:759]
    at mx.managers::LayoutManager/doPhasedInstantiationCallback() [E:\dev\4.0.0\frameworks\projec ts\framework\src\mx\managers\LayoutManager.as:1072]

    I don't know what I did wrong.

    Here's my code for the application:

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:fx s:WindowedApplication ' http://ns.Adobe.com/MXML/2009 "
    xmlns:s = "library://ns.adobe.com/flex/spark".
    xmlns:MX = "library://ns.adobe.com/flex/mx" creationComplete = "windowedapplication1_creationCompleteHandler (event)" >
    < fx:Declarations >
    <! - Place non-visual elements (e.g., services, items of value) here - >
    < / fx:Declarations >
    < fx:Script >
    <! [CDATA]
    Import mx.events.FlexEvent;
    public void handleKeyDown(event:KeyboardEvent): void
    {
    Display.Text = "key has been pressed:"+ event.keyCode;»
    }

    protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
    {
    stage.addEventListener (KeyboardEvent.KEY_DOWN, handleKeyDown);
    }

    []] >
    < / fx:Script >
    < s:Label id = "Display" / >
    < / s:WindowedApplication >

    Hope you can help me to find out why it didn't work. Thank you.

    You use the incorrect event. Change to applicationComplete creationComplete and it will work.

    Kind regards

    Select this option.

  • Global keyboard event listener?

    Is it possible to create a global keyboard event listener that is unrelated to a window, button, or other user interface element?  The best I could get to add the event to the window listener.  This only works if the window is active.  If the user clicks outside the window and then the receiver for the keyboard does not work.  In addition, when the dialog box appears first of all, it won't work until after the user has made some type of interaction with the window.  I want is to have keyboard shortcuts for users that work regardless of the place where they clicked on the screen, even if the dialogue window is not 'active'.  Is this possible?

    Here is the code I use to the receiver of keyboard for the window.

    mywindow.addEventListener ("keydown", function (k) {keyListen(k)});
    function keyListen(k){if(k.keyName=="Z"){alert("Do stuff here");}}
    

    I don't think that you can create listeners of world events, as for the first appearance of the dialog box, I solved this problem in my script: scripts buliarca BCM_ExtendShortcuts UI by a button activates the event listener to this button. A problem with attach listeners to window, it's in CC2015 events can only be attached to controls and not windows. Setting for windows works in CS6...

  • Keyboard event handler

    I want to process keyboard events and execute a method on every key stroke. It works, but the value sent is a character behind what is actually typed

    < af:resource type = "javascript" >

    function doSomething (evt) {}

    var _keyCode = evt.getKeyCode ();

    model var = evt.getSource ();

    Alert (COMP.getSubmittedValue ())

    AdfCustomEvent.queue (comp, "KeyboardEvent",

    {

    FValue: comp.getSubmittedValue)

    },

    (false);

    evt. Cancel();

    }

    < / af:resource >

    < af:inputText label = "Label 1" id = "it1' autoSubmit ="true">

    < af:clientListener type = "keyPress" method = "doSomething" / >

    < af:serverListener type = "KeyboardEvent" method="#{pageFlowScope.myBean.handleKeyboardEvent}"/ >

    < / af:inputText >

    So, if I type

    ADF

    The first time I will get an empty string, the second time 'a' and the last time "ad".

    Is there a way to get the current value?

    JDev 11.1.2.4

    My work now code I used the keyPressed instead of keyUp event. So now, getSubmittedValue returns the correct value.

    I can't use autosuggest because what the user types is not the value that is to be submitted. For example, the user is looking for a phone country code, it will start to type Ger and the suggested value is Germany + 49 but the value which should be in the form is + 49 and not Germany + 49.

  • If (child on screen) AS3 {play child} (keyboard.event)

    Maby someone can help me with this? :

    I have this script:

    var answerA:Array = [];

    function answerF(answerS:String,x:int,y:int,space:int):void {}

    stiff var: int = answerS.length;

    Word of the var: int;

    If ((answerS.length % 2) == 0) {}

    Word = (((raides * 150) + ((raides-1) * space)) / 2-150);

    } else {}

    Word = (((raides-1) * 150) + ((raides-1) * space)) / 2) - 75;

    }

    var nextX:int = x - Word;

    var C: Class;

    var letter: MovieClip;

    for (var i: int = 0; i < answerS.length; i ++) {}

    C = Class (getDefinitionByName (answerS.charAt (i)));

    Letter = new C();

    addChild (letter);

    answerA.push (letter);

    letter.x = nextX;

    letter.y = y;

    nextX += letter.width + space;

    }

    }

    On the library, I have objects whose names A, B, C, D, E, f... to Z

    This script adds letters from the library. With this script all ok it works perfectly for me, but I want keyboard event for each letter to play but now I don't know how to do this.


    I have a script:


    stage.addEventListener (KeyboardEvent.KEY_DOWN, AKeyDown);

    function AKeyDown(event:KeyboardEvent):void {}

    If (event.keyCode == Keyboard.A) {}

    A.Play ();

    }

    }

    This script works then object instance name.

    And I want to do:

    stage.addEventListener (KeyboardEvent.KEY_DOWN, AKeyDown);

    function AKeyDown(event:KeyboardEvent):void {}

    If (event.keyCode == Keyboard.A) {}

    If child with class name an exist on screen}

    playing the object with the name of class A


    } else {}

    var erreur.r: Sound = new eror();

    errorR.play (0, 1);

    }

    }

    }

    What you need to do, is to give each child a name as you load them.  Then, you can target with their name property.

    var C: Class;

    var letter: MovieClip;

    for (var i: int = 0; i<>

    C = Class (getDefinitionByName (answerS.charAt (i)));

    Letter = new C();

    letter. Name = answerS.charAt (i);

    addChild (letter);

    answerA.push (letter);

    letter.x = nextX;

    letter.y = y;

    nextX += letter.width + space;

    }

    }

    stage.addEventListener (KeyboardEvent.KEY_DOWN, AKeyDown);

    function AKeyDown(event:KeyboardEvent):void {}

    trace ("key pressed:" + string.fromCharCode(0)) (event.charCode));
    var ltr:MovieClip = MovieClip (getChildByName (string.fromCharCode(0)) (event.charCode)));
    LTR. Play();

    }

    You will probably need to convert the string.fromCharCode(0)) (event.charCode) uppercase if you are naming them with capital letters.

  • Capture the event media export in Adobe Premiere

    We develop a html5 Adobe first Extension. The extension is important files to the editor of our archives. The files have two versions. HI-res and low resolution.  We import versions low-resolution to the editor. We want to change the path of the file of bass to high resolution when the user finishes his work and exports media (file-> export-> Media). Is there a way to capture the event of export and change the paths of the files?

    You can change the path using changeMediaPath() on project items.

    There is no way to capture the export event when the user is not interacting with your Panel. However, your panel could have a button "replace all the lower-res with high resolution.

    NOTE: If the dimensions of the image are different between lo-res and hi-res, your movies will look strange (images will be much too big, or too small). Use proxies with the same dimensions as the images high resolution.

  • sequence of images, add the keyboard event loop?

    Hi all

    I have a sequence of 3d images that I want to run with the mouse and drag.

    So far I succeeded with that.

    Also added keyboard event.

    stage.addEventListener (KeyboardEvent.KEY_DOWN, keyPressed);

    function keyPressed(event:KeyboardEvent):void
    {
    If (event.keyCode is 39)
    {
    images_mc.gotoAndStop (images_mc.currentFrame + 1);
    }
    Else if (event.keyCode == 37)
    {
    images_mc.gotoAndStop (images_mc.currentFrame - 1);
    }
    }

    I tried looping event, that is, playing continuously until the button is pressed.

    Help, please.

    Thanks in advance.

    function keyPressed(event:KeyboardEvent):void

    {

    If (event.keyCode is 39)

    {

    If (images_mc.currentFrame<>

    images_mc.gotoAndStop (images_mc.currentFrame + 1);

    }

    else {}

    images_mc.gotoAndStop (1);

    }

    Else if (event.keyCode == 37)

    {

    {if(images_mc.currentFrame>1)}

    images_mc.gotoAndStop (images_mc.currentFrame - 1);

    }

    else {}

    images_mc.gotoAndStop (images_mc.totalFrames);

    }

    }

    }

  • Help with keyboard events

    Hi, I'm a rhythm box design in flash pro Cs6 actionscript 3.0 and I am trying to add a keyboard event that will trigger a key event that I have created loan, I can create the event to play the sound, but is not what I want, can I call for the button click event moves on the key event triggering the sound Here is an example of one of my buttons... code btn, thanks if anyone can help.

    import flash.events.KeyboardEvent;

    /*

    playsound2.fla

    PlaySound with additional features:

    Added TextBox.

    Display the ID3 information

    */

    btn.addEventListener (MouseEvent.CLICK, playSomeSound);

    function playSomeSound(e:MouseEvent)

    {

    var req:URLRequest = new URLRequest ("Savage.mp3");

    var s:Sound = new Sound (req);

    s.addEventListener (Event.COMPLETE, onSoundLoaded);

    s.addEventListener (Event.ID3, onID3Info);

    }

    function onSoundLoaded(event:Event):void

    {

    var localSound:Sound = event.target as Sound;

    localSound.play ();

    }

    function onID3Info(e:Event):void

    {

    var id3Props:ID3Info = e.target.id3;

    var sOut:String = txt.text = "";

    for (var propName:String in id3Props)

    {

    sOut = propName "=" + id3Props [propName] + "\n";

    trace (sOut);

    txt.appendText (sOut);

    }

    txt. Text = id3Props.comment;

    }

    var ba: ByteArray = new ByteArray();

    var gr:Sprite = new Sprite();

    Gr.x = 5;

    Gr.y = 50;

    addChild (gr);

    var time: Timer = new Timer (50);

    time.addEventListener (TimerEvent.TIMER, timerHandler);

    Time.Start ();

    function timerHandler(event:TimerEvent):void

    {

    SoundMixer.computeSpectrum (ba, false);

    var i: int;

    Gr.Graphics.Clear ();

    gr.graphics.lineStyle (2, 0xFF0000);

    gr.graphics.beginFill (0x00ff00);

    gr.graphics.moveTo (10, 10);

    Draw a circle. ;

    var w: uint = 15;

    for (i = 0; I < 512; i += w)

    {

    var t:Number = ba.readFloat ();

    var n: Number = (t * 200);

    gr.graphics.drawCircle (i, 0, - n);

    }

    }

    You can use the following to trigger your button event:

    btn.dispatchEvent (new MouseEvent (MouseEvent.CLICK));

  • Capture the event of hyperlink and value

    Hi all

    I have a hyperlink on one column of the report, and when I click on the hyperlink, need me a URL. Now, I need to enter the time, the user has clicked on the URL and update a DB table column. So I created a dynamic event to update something, but I'm not able to get the hyperlink event. When I select the event 'Click' and 'Selection Type' as 'Élément', the report column does not appear on the LOV item (s). Can dynamic Actions be based only on the click on page elements?

    If so, are there any other to capture this event Hyperlink and set the value? Also, as my target 'Column link' is 'URL', I can't put any value for items it!

    Help, please
    Robet

    Robette,
    Add a

    wwv_flow.g_unrecoverable_error: = TRUE;

    After the line of appeal owa_util.redirect_url

    Otherwise the PLSQL process continues to request/get the next page and the piece of code that doesn't stop that.

  • Error 1119: Access of a property may not set with a keyboard event

    Scene 1, Layer 'layer 1', frame 1, line 5.1119: access of property may be undefined LEFT through a reference with static type class.
    Scene 1, Layer 'layer 1', frame 1, line 6.1119: access of property may not set down through a reference with static type class.
    Scene 1, Layer 'layer 1', frame 1, line 7.1119: access of possibly undefined property BACK through a reference with static type class.
    Scene 1, Layer 'layer 1', frame 1, line 8.1119: access of property may not set through a reference with static type class.

    I think that to have public but do not know how the value Keyboard.Event.LEFT, UP, DOWN, RIGHT.

    import flash.events.KeyboardEvent;

    stage.addEventListener (KeyboardEvent.LEFT, characterMove);

    stage.addEventListener (KeyboardEvent.DOWN, characterMove); ------Headphones of events for left keyboard etc.

    stage.addEventListener (KeyboardEvent.UP, characterMove);

    stage.addEventListener (KeyboardEvent.RIGHT, characterMove);

    new audience; function characterMove(evt:KeyboardEvent):void {------function to move the person}

    Switch (evt.keyCode) {}

    case Keyboard.LEFT:

    Person.x-= 20;

    case Keyboard.RIGHT:

    Person.x += 20;

    case Keyboard.DOWN:

    Person.y-= 20;

    case Keyboard.UP:

    Person.y += 20;

    by default:

    trace ("keyboard event error")

    }

    }

    Your listeners must specify KeyboardEvents and upward, DOWN, LEFT, RIGHT aren't KeyboardEvents, they are key keyboard codes.  Using KEY_UP and KEY_DOWN instead of each of them in the headphones.

  • Send the keyboard event of the clip loaded by the parent mouse click

    Hello. I'm building a swf wrapper that loads the third-party swf games. The customer wants a button in the package, that will send a keyboard event in the loaded swf file.

    Can someone give me hand on how to build an event to send in the wrapper which penetrates into the loaded swf file?

    Thank you very much!

    After that is finished loading:

    MovieClip (yourloader.content) .dispatchEvent (new KeyboardEvent (somekeyboardevent));   If the loaded swf file is a movieclip

  • With the help of a keyboard event to play a different scene

    I want the user of my game to be able to press the space bar and to be considered as a new scene. I know how to do this with a button, but I can't understand the code to use for a keyboard event.

    Can someone help me understand how pressing the SPACEBAR reading a new scene?

    If the intention is really to stop at these images, use gotoAndStop(), gotoAndPlay() instead.  If you say something to gotoAndPlay where it already, is any stop() command that you could have in this context is already sold out, to run.

Maybe you are looking for