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...

Tags: Photoshop

Similar Questions

  • Keyboard event listener does not work in the browser

    Is there a reason why a keyboard event listener would not work if the flash is embedded in an HTML element? The rest of my game runs well in the background, but I can't launch the movieClip "nextCar." My code is below, if that makes a difference...

    goNow function (event: KeyboardEvent): void {}
    thisOtherKey = event.keyCode;
    If (thisOtherKey == 32) {}
    nextCar.gotoAndPlay (2);
    parkingQue.play ();
    tent ++;
    }
    }
    stage.addEventListener (KeyboardEvent.KEY_DOWN, goNow);

    This is perhaps a silly question, but have you tried to click on your swf file once it opens in the browser and then try the keyboard controls?

    I don't know any problems that may cause debugging workwhen event listeners, but not in a browser.  So I think that maybe your just not well centered on the swf.

  • Strange problem with the keyboard event listener

    I have a full screen touch app. To close the application, I set an event listener on keyboard for the key "0". I don't want the press user due to some restrictions Alt + F4 key combination. Problems begin when the application loses focus. Here's the code;

    protected function onComplete(event:FlexEvent):void
    {

    this.setFocus ();
    this.addEventListener (KeyboardEvent.KEY_DOWN, trapKeys, true, 0, true);

    }

    private void trapKeys(e:KeyboardEvent):void {}

    If (e.keyCode == 96) {}
    This.Close ();
    }

    Else if (e.keyCode == 48) {}
    This.Close ();
    }

    }

    When the user change the screen to a different with Alt + TAB application, or any other combination of keys flex app loses focus and does not work when he turns back to my app "0". How can I solve this problem?

    Thanks in advance.

    Hi, Ahmed.

    I have absolutely no problem with the solution you are trying to set up - you use mode full-screen interactive mode of keyboard?

    Please consider:

    on full add keyboard listener

    protected function applicationCompleteHandler(event:FlexEvent):void

    {

    this.stage.addEventListener (KeyboardEvent.KEY_DOWN, trapKeys);

    };

    //

    protected function applicationActivateHandler(event:AIREvent):void

    {

    If (this.stage)

    {

    switch the State to display full-screen when activated

    If (this.stage.displayState! = StageDisplayState.FULL_SCREEN_INTERACTIVE)

    {

    this.stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;

    };

    };

    };

    //

    private var exitHandled:Boolean = false;

    on NUMBER_0 | NUMPAD_0 exit-close

    protected function trapKeys(event:KeyboardEvent):void

    {

    If ((event.keyCode is Keyboard.NUMBER_0

    || event.keyCode is Keyboard.NUMPAD_0)

    (& this.exitHandled == false)

    {

    exitHandled = true;

    this.stage.removeEventListener (KeyboardEvent.KEY_DOWN, trapKeys);

    This.Close ();

    };

    }

    (Note: applicaton of the events 'applicatonComplete' and "applicationActivate" are routed to over managers)

    Kind regards

    Peter

  • 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.

  • Launch Global event listener when auto start MyApp

    What I was trying to do:

    MyApp has an alternative entry point and the graphical user interface.

    access to choice, I wanto save a folderlistener that triggers a global event to trigger an email sending process.

    so far, I've only had the entire process running only if I join the global event listener in the GUI part, it means when myapp GUI stood then go global Stanley knitted.

    but I want Global event listener remains all the time, how can I do this?

    I did some research in this Ant but just couldn't understand it

    any responses appreciated.

    my code:

    ============================================

    SerializableAttribute public class MyApp extends UiApplication implements FieldChangeListener, GlobalEventListener
    {

    Public Shared Sub main (String [] args) throws AddressException, ClassNotFoundException
    {
    MyApp PAP;
    If (args! = null & args.length > 0) {}
    {If (args.length > 0 & {args [0].equals("Auto-MyApp")})}
              
    Entered another application by the entry point.
    Turn on folderlistener at startup.
    FolderListenerApp.waitForSingleton ();
               
    }
    else {}
    PAP = new MyApp();
    theApp.enterEventDispatcher ();
    }
         
    }

    private void AddGlobalEvent() {}
    addGlobalEventListener ((GlobalEventListener) this);
    }

    Public MyApp() throws AddressException, ClassNotFoundException
    {
           
    ........

    AddGlobalEvent();
           
           
    ........
           
       
    }

    ' Public Sub eventOccurred (guid long data0 int, int data1, the object object0,)
    Object1 object) {}
           
    Logger.logEventError ("in eventOccurred...");
    Is it the GlobalEvent we expect?
              
    If (guid is 0xa4c7e78a6c3fe109L)
    {
    Yes.

    FolderListenerAction f = new FolderListenerAction();
    New Thread (fa) m:System.NET.HttpListener.start ();
    }
           
    }

    }

    ==================================

    Check out this tutorial that I posted earlier, it shows an application that is divided into a background process (extends the Application and begins when the operating system starts) and a process of foregroud/AC (extends UiApplication).

    Both are implementing GlobalEventListener and use it to talk with them

    http://supportforums.BlackBerry.com/T5/Java-development/tutorial-communicate-between-apps-processes/...

    Scroll down to the post on that date "2010-06-19 23:22"to the GET, the corrected version of the code.

  • 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!

  • How to define the event listener AFTER_ACTIVATE for each document

    Well, I want to be able to connect an AFTER_ACTIVATE event listener to any document that is created or opened. Is anyway to do this?

    "update of certain variables"? You mean, like global variables in a persistent script?

    I suggest that you could much better be architecting your script differently.

    Maybe to have a global object that your script consults the active document, instead of using a global variable.

    Or put your data inside the document with. insertLabel().

    Global variables are generally a bad idea. In this case, it seems that you are trying to mimic the local scope by using event handlers, and this sounds a bit scary for me.

  • Detection and event listener? Is there such a thing?

    I was wondering if I have a Stanley event (mouse, keyboard and enterframe,... event) who goes off, and when he finished his event.

    something that is able to detect the finished event listener and fire on another series event.

    It works more like MOTION_FINISH in TweenEvent, but it is only available for TweenEvent only, what happens if I want to detect a mousclick, keyboard enterframe or even touch event?

    Is there such a thing? Thanks in advance.

    If you have an event listener to catch the occurrence of an event, normally have a function handler for this listener such as additional measures can be implemented.

    If an event is detected, the event listener has finished processing it, as soon as it started.  It intercepts the event occerence and triggers it corresponding to the handler function to take action.  There is no delay in this transformation.

    Events are instantaneous occurrences, they are not something that happens over time.  Even the MOTON_FINISH event occurs as soon as the Tween ends its movement.   If you look to the top of the event class in the help, early documents, you will find a long list of all the event subclasses that are extensions of it.  And each of these subclasses are likely to have a list of constants.  MOTION_FINISH, CLICK, ENTER_FRAME, etc. are all constants, and each of them represents the end of a particular set of treatments.  A CLICK event occurs when a MOUSE_UP event occurring after an event MOUSE_DOWN... each of them happens to an instance of time, not over time.

  • Event listener does not not in a class

    Hello!

    I have a problem, I have 2 files, one that is the main .fla, which is called game.fla and another file named PacMan.as.

    I just started with as3 and would like to know why I can´t create a KeyboardEvent on the .as file.

    I created a movieclip which would be the player and linked to the. as. I checked and it works when I use the trace command in the .as file.


    But when I add a function and an eventListener trace command dosen´t work...

    Here's what I have:

    *. As leader (PacMan.as):

    PacMan class
    package gamecontent.classes
    {
    import flash.display.MovieClip;
    import flash.ui.Keyboard;
    import flash.events. *;

    PacMan/public class extends MovieClip
    {

    public void PacMan()
    {
    var newPacMan:PacMan = new PacMan;
    newPacMan.addEventListener (KeyboardEvent.KEY_DOWN, testFunction);

    trace ("class expenses");
    }
    function testFunction(e:KeyboardEvent):void
    {
    trace ("key...");
    }
    }


    }

    *.fla (game.fla) file, I just "spawn" the reader of the library:

    Player: PacMan var = new PacMan();


    addChild (player);

    Position of objects...
    Player.x = 39;
    Player.y = 559;

    Any help is much appreciated...

    Hello

    try to add the listener to the stage instead:

    stage.addEventListener (KeyboardEvent.KEY_DOWN, testFunction);

    This will pick up all keyboard events - if you add a keyboard listener to a specific object, the event only fires if this object has focus

  • A function can receive from a keyboard event or a mouse event or there may be only one?

    I decided to add some keyboard functions to my program.  All my functions, I wrote require a mouse event to pass to them.  I wonder if there is a better way to perform these functions of mouse event rather than take the contents of these functions and create a function that is called in a mouse event function OR a function of keyboard events.

    What I mean is that I begin to change the functions of mouse event that I don't have only one line inside of them, which runs a separate function. This same separate function that I run using a keyboard to input as well.  It seems a little redundant to me. Any thoughts?  Thank you.

    In addition to other comments, since MouseEvent and KeyboardEvent extends event, you can type argument as event:

    function myHandler(e:Event):void {}

    code

    }

    The only problem with this is that if you write code within the listener based on a specific event parameter - you will need to mount e argument as such in any case.

    Another solution would be to make argument an object. In this case to the compilation and runtime it will be perceived as valid a data type:

    function myHandler(e:Object):void {}

    code

    }

    Typing is no argument at all (like e: *) can cause inconvenience more typing at least to the object.

  • Caps Lock event listener

    Hi all

    I spent some time with event listeners today and I thought listening to the status of the caps lock.

    Not found a way to check it out then maybe that the listener is the best way to do it.

    Any thoughts on how this can be achieved? It would be very useful for purposes of connection to see if the user types with caps lock on.

    A little Up/DOWN event, CapsLock KeyCode is 20. But you must use the Keyboard.CAPS_LOCK constant instead.

    In a keyboard event handler:

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

    true if capslock has been pressed

    }

    To check if the key is on and off, follow these steps:

    If (Keyboard.capsLock) {}
    true if shift caps lock is enabled. false otherwise.
    }

    Add a listener like this:

    public function addHandler (): void {}
    Called from creation complete event of the app.
    Listener to handle any event keyboard KEY_DOWN:
    this.addEventListener (KeyboardEvent.KEY_DOWN, handleKeyDown);
    }

  • How can I add an event listener

    I tried to add an event listener for this object:

    < mx:Button id = "calculateButton".
    label =""
    toolTip =""
    styleName = "enable".
    Click = "swapToResultsState ()" "
    rollOverEffect = "{glowButton}".
    = Red "-100" horizontalCenter = "0".
    tabIndex = "85" / >

    by using this code:

    calculateButton.addEventListener (KeyboardEvent.KEY_DOWN, swapToResultsState);

    who gave this error:

    Several markers to this line :-1120: access of undefined property calculateButton. -1120: access
    undefined property swapToResultsState.

    What I am doing wrong?

    Keyboard events spread so you do not need to forward.  Just can't do anything if keyCode is 9

  • How can I create an event listener for the change of variable shared or similar?

    Hello

    I have a 'big' 6 devices communicating measurement system via the TCP protocol. The system is designed to use REST (the representative State transfer) with JSON (JavaScript object notation).

    Now, I need to add labview program to this environment. I've implemented a solution to 'work' with the help of this forum. Thank you for this! Now, I need to do better (currently no timestamps, large delays, etc.).

    I currently have a web service deployed using http-get as input. My web service .vi is just passing the web entrance to shared variables that are then questioned in real measurement program. Reason is that when I put the measurement program directly to the web service, it does not (something about rights and dependencies). Measurement program includes one third of the owners (Instron) drivers. Also I would not direct access via the network to our mechanical testing device potentially dangerous.

    Now, I want to change the message from the web services .vi commensurate .vi. Currently I have a loop of 10ms to query for changes in the shared variable. Is there a better way to do this? I thought create a listener to the shared variable change events.

    In addition, if you have any ideas (preferably, working code example) how to make the interface between labview and TCP-JSON I would really appreciate it.

    BR,

    Juha

    Currently in LabVIEW, the only way to create an event listener or event NSV is to use the DSC toolkit.  Most of the time the DSC is a very expensive tool that simply encapsulates the functionality that is built into the motor of the PSP and OAS and which is accessible to anyone who can program in LabWindows/CVI.

    http://zone.NI.com/reference/en-XX/help/370051P-01/CVI/libref/cvicnvcreatesubscriber/

    If you want to collaborate, I would like to create a small library of LV that would create a base SV events using a vi LV reminder or possibly passing return user LV event which is how works the DSC toolkit.  I asked OR several times to explain how do this and they're very tight discreet about it.  I guess that they do not want to give users LV less reason to buy the DSC.

  • How in fact blackberry event listener

    Hi, m havin a little doubt

    Cvent JDE listener how actually works?

    They keep listening in the background for the event

    OR

    When the event occurs, then the OS itself call all the event listener for this event?

    I think that he shud of same way java event listeners work:

    Follow the link

    http://www.JavaWorld.com/JavaWorld/javaqa/2000-08/01-QA-0804-events.html

  • 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

Maybe you are looking for

  • How to return to Windows Media Player 10?

    I am running Windows XP Media Center Edition. I want to install adriver for a Creative Zen Touch MP3 player. This operation requires me to go back to Windows Media Player 10, but I can't understand how do. I tried turning on Windows Media Player 11 a

  • Web browser Internet Explorer

    I use Windows Vista Home Premium and have Intenet Explorer 9 as my browser... I keep getting notices to this day my Fire Fox or Google Chrome browser as curiosities don't except my browser more. I can't change either or and if so, I have to delete my

  • Unable to connect to the ftp to EA4500 usb storage device

    I am unable to connect to my hard drive on the EA4500 from a remote device (pc or mobile) using the ftp protocol. The drive is a WD 1 TB and is supported. I use cisco smartwifi to set it up. The player is accsessable on my local network, capable of m

  • Can not install programs

    I have a tray application that opens for smart web printing.  I don't know what it is.  I'm not able to run my antivirus AVG protection or uninstall or upgrade.  What is the cause?  I can run a download, but it is not really the installation.

  • What are small &#60; | &#62; is called when the Details view is used, anyone?

    Thank you