Check Keyboard events

Hi
I have a library written in C++,used from Cocoa, that must check keydown events on CTRL keyboard key.
If possible, I´d like to use something similar to Windows GetAsyncKeyState( VK_CONTROL ). Do you know how can I get this on MacOSX?
Thanks
Pablo J. Royo

implement KeyListener in your panel. Then in the keyTyped method use the keyEvent.getKeyChar() method to get the char of the key they pressed. If it's 'c' change some Color variable used in the panel's paint method to determine the color of the oval. Don't forget to add the KeyListener to the panel with panel.addKeyListener(panel). Do you understand?

Similar Messages

  • Detecting keyboard events outside the application

    is it possible to click a key when the air app is out of focus, and will trigger an event in air?

    You may want to check the security documentation on that one.  I don't know of many non-OS apps that can intercept keyboard events without focus.  Keystroke sniffers on the other hand ....

  • Reset the time when he is typing(keyboard event) any info in from.

    Hi All,
    We have implemented auto session logout(if user is ideal for 15 mins one message popup will come and after 5mins user gets  logged off) in our portal and it is working fine. when user navigate to other page the timer is getting reset  but if user working in same page for 15 mins popup message comes and if is not clicking 'ok'user gets logged off .
    For navigation i am using EPCM.subscribeEvent("urn:com.sapportals:navigation", "Navigate", pop);
    My requirement is to reset the time when he is typing(keyboard event) any info in from.
    Please provide your inputs.
    Thanks,
    Santosh.

    Dear Santosh
    Regarding events between WD and Portal you need to consider the interface
    IF_WD_PORTAL_INTEGRATION
    Please check this to see how it is done
    http://wiki.sdn.sap.com/wiki/display/Community/Usingportaleventtocommunicatemultipledatabetweendifferentwebapplication%28WDAandBSP%29
    Kind Regards
    /Ricardo Quintas

  • Movieclip.x movement using keyboard event

    Hi, im working on a game project and i have a question about movie clip movement using keyboard event.
    Basicly i have a character on screen and it can move on the x axis using the left and right buttons.
    Im making my charater move by changing the x value of the character movieclip but i find very it laggy and not smooth and if im going point by point
    then it's too slow.
    Whats the best way to make the character move so that the transition will be smooth.

    Ok obviously you've left out where you add your eventListener, i'll assume that's a KEY_DOWN event. When the user holds down a key, that key event is triggered once immediately and then after a pause it is triggered at regular intervals. Check this out by holding down the up/down arrow and watching this browser window scroll.
    That's not the movement you'd be looking for when moving a character in a game. Instead, you'd be setting a variable on KEY_DOWN to indicate the character direction - it could be an integer for example that you increase by 1 if the user pressed RIGHT or decrease by 1 if the user pressed LEFT.
    In addition to your KEY_DOWN eventListener, you could have an ENTER_FRAME and  KEY_UP eventListeners set up:
    The enterFrame event handler could move the character in the direction specified in your direction variable. This is where you might ensure your character doesn't go beyond its limits in both directions.
    In the keyUp event handler, you could do the converse of what you did in the keyDown handler(increase by 1 if the user released LEFT, decrease by 1 if the user released RIGHT).

  • CS2: Listbox and keyboard events

    Hello all,
    I have a listbox widget in a Palette, I need to catch keyboard events specifically I need to be notified when the user presses the RETURN key.
    I checked the PanelTreeView sample which defines a custom event handler but functions like KeyDown or KeyCmd are never called despite "CanHaveKeyFocus" has been modified to return kTrue.
    How can I be notified when user presses the RETURN key in the PanelTreeView listbox?
    Thanks in advance ...
    Jorge Martinez

    If the StageWebView has focus, you should be able to capture only the hardware key events (like BACK, ..). All the others are handled internally by StageWebView.
    Do you see otherwise? If yes, can you post your application ?
    Thanks,
    Raul

  • Capturing all keyboard events.

    I'm using the keyboard to control a mobile robot through a Java applet.
    I also have lots of other buttons in the applet. I don't want to add KeyListeners to all of the buttons. So is there a way to directly capture all keyboard events? So that no matter which button has the focus, the keyboard events would be processed?
    Thanks a lot!

    I don't want to add KeyListeners to all of the buttons.You could use a single KeyListener and add it to each button.
    So is there a way to directly capture all keyboard
    events? So that no matter which button has the focus,
    the keyboard events would be processed?I don't know if this works or not, but check out Toolkit.addAWTEventListener().

  • Keyboard events going to InDesign and not on textbox

    Hi,
    I have ported a project from InDesign CS2 to InDesgn CS3 on Mac. I have dialogs in rsrc file (not converted to nib file) which I am also using on XCode.
    Now the problem which I am facing is that when typing in a textbox then keyboard events are going to InDesign and only those events which are not handled by InDesign is received by my textbox.
    Has anyone experienced the same problem before?
    Any help will be appreciated.
    Regards,
    Rahul Rastogi

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).<br />
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]<br />
    <br />
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.<br />
    You can use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.<br />
    You have to close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • Keyboard events in Flex mobile

    I have a desktop application where I handle autocomplete and some other checks using the Keyboard events. Now porting the same app to Mobile devices but I am not able to get the Keyboard events. How can I get those or are there any alternatives for Keyboard events on Mobile devices?

    Hi there,
    If you are recording in Training mode then by default Captivate should include click boxes in your slides. You can assign keyboard shortcuts to those click boxes by carrying out the following steps:
    1. Double-click on one of your Click Boxes.
    2. In the Click Box section of the dialog box click the Select Keys... button.
    3. Select the option Attach a shortcut
    4. To perform an Undo choose Ctrl and then from the Letter menu choose
    Note: To get the learner to Shift + Click, select the option SHIFT
    5. Click OK to Close the Shortkey dialog box.
    To simulate an Undo you would then need to branch to a slide where the original action was performed. Here you can either use the On success options Go to Previous Slide or Jump to Slide and then specify the slide number.
    As for simulating selecting multiple items, again you would carry out similar steps. Depending on how your project has been setup you would either set the On success action to Continue or to  Go to next slide.
    The way I tend to work is that I have each of items I want to select on separate slides and then add a click box with the keyboard shortcut Shift attached. When the learner clicks on the first click box I then move to the next slide and so on. Naturally, this does not account for allowing the learner to randomly select the items. To accomplish that, you would need to set up some pretty complex branching.
    HTH
    Best - Mark
    Visit the macrofireball blog

  • [SOLVED] PgUp/PgDown Improperly Spawn Two Keyboard Events

    After doing an upgrade (pacman -Syu), I can no longer use the following keys on my keyboard without unappreciated consequences:
    - PgUp
    - PgDown
    - now, apparently, the Left arrow
    When I use xev, I get two separate events for every one real keyboard event, with two keycodes.
    For example, this is what happens when I press PgUp:
    KeyPress event, serial 24, synthetic NO, window 0x1800001,
    root 0xae, subw 0x0, time 1850204, (679,556), root:(680,571),
    state 0x0, keycode 112 (keysym 0xffaf, KP_Divide), same_screen YES,
    XLookupString gives 1 bytes: (2f) "/"
    XmbLookupString gives 1 bytes: (2f) "/"
    XFilterEvent returns: False
    KeyPress event, serial 24, synthetic NO, window 0x1800001,
    root 0xae, subw 0x0, time 1850204, (679,556), root:(680,571),
    state 0x0, keycode 99 (keysym 0xff55, Prior), same_screen YES,
    XLookupString gives 0 bytes:
    XmbLookupString gives 0 bytes:
    XFilterEvent returns: False
    MappingNotify event, serial 27, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248
    KeyRelease event, serial 27, synthetic NO, window 0x1800001,
    root 0xae, subw 0x0, time 1850306, (679,556), root:(680,571),
    state 0x0, keycode 112 (keysym 0xffaf, KP_Divide), same_screen YES,
    XLookupString gives 1 bytes: (2f) "/"
    XFilterEvent returns: False
    MappingNotify event, serial 27, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 8, count 248
    KeyRelease event, serial 27, synthetic NO, window 0x1800001,
    root 0xae, subw 0x0, time 1850306, (679,556), root:(680,571),
    state 0x0, keycode 99 (keysym 0xff55, Prior), same_screen YES,
    XLookupString gives 0 bytes:
    XFilterEvent returns: False
    I've checked xmodmap -pke, but I have no idea what it means:
    keycode 99 = Prior NoSymbol Prior
    keycode 112 = KP_Divide XF86_Ungrab KP_Divide XF86_Ungrab
    Any help would be appreciated. Needless to say, this is pretty annoying when I'm trying to edit code and it searches my document instead of scrolling up, or capitalizes words (some vim feature I had previously never known about, and will most likely never use).
    Last edited by secretrobotron (2010-06-24 15:09:05)

    I'm pretty sure I'm using the latest xorg. I installed a fresh version of arch a couple months ago.
    My xorg.conf has about six lines concerning keyboards, most of which are
    Section "InputDevice"
    Identifier "Keyboard0"
    Driver "keyboard"
    Option "XkbLayout" "us"
    EndSection
    and the other being
    InputDevice "Keyboard0"
    in the ServerLayout section.
    Is there a newer way to do this? Perhaps omitting it altogether?
    I'm using xmonad, and I checked my keybindings in xmonad.hs to see if I had anything hilarious. Alas, I found nothing.

  • Flex 4 does not dispatch keyboard events for ENTER key.

    Hello everyone. I think I have a strange problem with Flex 4 Beta (4.0.0.8909). My application has had event listener for keyUp event for a month now and suddenly (two days ago) I've noticed that keyUp event is not dispatched for ENTER (ALT also) key. Anyone know why? By the way, I've tried this with keyDown event, also 4.0.0.8847 version of SDK - still the same: no keyboard events for ENTER (and ALT) key.
    Here is the sample application that has got this issue:
    <s:Application
       xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/halo"
       minWidth="640" minHeight="480"
       keyUp="application1_keyUpHandler (event)">
       <fx:Script>
          <![CDATA[
             import mx.controls.Alert;
             protected function application1_keyUpHandler (event: KeyboardEvent):void
                Alert.show ("Key up: " + event.keyCode);
          ]]>
       </fx:Script>
       <s:layout>
          <s:BasicLayout/>
       </s:layout>
       <s:TextArea verticalCenter="0" horizontalCenter="0" width="200"/>
    </s:Application>
    If you run this application and try typing anything in a TextArea you will get alerts with key codes. However, if you press ENTER (or ALT), you will get no alert.
    I'm pretty sure the code above is right so that means there is a bug in latest nightly builds of SDK (i would swhitch to an older build if i knew which one does not have this bug).
    Any ideas?

    Flex harUI wrote:
    That's true, but in this case, I think the text editing code is eating ENTER key in order to prevent parents from seeing it and acting on it (like a submit button).  We'll see if we can find a way around that.
    You can get the ENTER key now by listening in capture phase.
    Alex Harui
    Flex SDK Developer
    Adobe Systems Inc.
    Blog: http://blogs.adobe.com/aharui
    The enter key isn't being disposed of by textedit, the attached example code works without error if you a- remove the alert box and b-set the focus to your text area on initialisation. I agree that pressing the enter key then calling a dialog box will result in the enter key being "gobbled up" as  the enter key is overridden by the dialog box code.
    I think the first suggestion should be to anyone don't use dialogboxes for testing code. If for some reason debugging isn't desirable instead of a trace statement a simple label  can be used as a 'fake' trace.
    David
    Message was edited by: David_F57: I worded this wrong, imho there is no need for a work around, the textarea component works as it should. When intercepting 'system' keycodes there is a need to consider the effect of the intercept and code appropriately to that end.

  • Keyboard Event Listener doesn't work in Browser

    Is there a reason why a keyboard event listener would not work if the flash is embedded in an HTML? The rest of my game is running fine in the background, but I can't launch the movieClip "nextCar." My code is below, if that makes any difference...
    function goNow (event:KeyboardEvent): void {
        thisOtherKey = event.keyCode;
        if (thisOtherKey == 32) {
            nextCar.gotoAndPlay(2);
            parkingQue.play();
            tries++;
    stage.addEventListener(KeyboardEvent.KEY_DOWN, goNow);

    This may be a silly question, but have you tryed clicking on your swf after it opens up in the browser, and then trying the keyboard controls?
    I don't know of any issues that cause event listeners to workwhen debugging, but not in a browser.  So, I'm thinking maybe your just not focused on the swf.

  • Disablying keyboard events in a JFrame.

    Hello,
    How is it possible to disable keyboard events for a specific JFrame and then (after a while) enable events again ?
    thank you,
    Rami

    Look at this program, events are send but you can't see the data in the fields.
    import java.awt.*;
    import java.awt.event.*;
    public class Nok extends Frame
    public Nok()
         super();
         setBounds(6,6,400,300);     
         addWindowListener(new WindowAdapter()
        {     public void windowClosing(WindowEvent ev)
                   dispose();     
                   System.exit(0);
         setLayout(new GridLayout(4,0));     
         add(new TextField("this is a text field"));
         add(new TextArea("this is a text area"));
         add(new Button("this is a button"));
         setVisible(true);
         Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener()
         {     public void eventDispatched(AWTEvent e)
                   System.out.println(""+e);
                   ((KeyEvent)e).consume();
         }   ,AWTEvent.KEY_EVENT_MASK);
    public static void main (String[] args)
         new Nok();  
    Noah
    import java.awt.*;
    import java.awt.event.*;
    public class Nok extends Frame
    public Nok()
         super();
         setBounds(6,6,400,300);     
         addWindowListener(new WindowAdapter()
    {     public void windowClosing(WindowEvent ev)
                   dispose();
                   System.exit(0);
         setLayout(new GridLayout(4,0));     
         add(new TextField("this is a text field"));
         add(new TextArea("this is a text area"));
         add(new Button("this is a button"));
         setVisible(true);
         Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener()
         {     public void eventDispatched(AWTEvent e)
                   System.out.println(""+e);
                   ((KeyEvent)e).consume();
         } ,AWTEvent.KEY_EVENT_MASK);
    public static void main (String[] args)
         new Nok();

  • In Flashplayer, I can crossover mouse and keyboard events. In IrfanView I cannot. Can this be fixed?

    My client uses IrfanView to play SWF files. Unfortunately, he does not use Flashplayer. In Flashplayer, I can crossover mouse and keyboard events with no problem. In IrfanView, the second I click a button, the keyboard events are disabled. Is there a fix?

    Hi Ned. I may have posted this issue a bit early, but this problem is also happening in Flashplayer 10. It's not exclusive to IrfanView.
    Here is something that I encountered during my testing, when I jump to scene 6 using the menu button, I have a play button to jump from one frame to the next frame that stops -- the keyboard events start working. But if all I am doing is jumping scene to scene with the mouse button, the keyboard events are disabled.
    I feel as if the keyboard events only work if I am playing frames in the scene. And if all I am doing is jumping scene to scene using the buttons, the keys will disable.
    I set up the mouse buttons inside a movieclip that all the scenes share. The mouse actionscript is in the movieclip. On the main timeline of each scene is an actionscript for the keyboard events, even though I had to change each function name.
    I feel the actionscript is setup pretty simple. I just wish clicking the buttons would not disable the keyboard events. This may sound redundant, but the keyboard events do the same thing if you use the mouse buttons. It's just preference for the client even though he will need to understand that using the mouse buttons override the keyboard events. He doesn't really lose functionality.
    Keyboard actionscripting below:
    import flash.events.KeyboardEvent;
    stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyEvent);
    function onKeyEvent(e:KeyboardEvent):void {
    var character:String=String.fromCharCode(e.charCode);
    if (e.keyCode==72) {
      gotoAndStop(1,"master");
    if (e.charCode==49) {
      gotoAndPlay(1,"Distributor");
    if (e.charCode==50) {
      gotoAndPlay(1,"Mirka");
    if (e.charCode==51) {
      gotoAndPlay(1,"Farm");
    if (e.charCode==52) {
      gotoAndPlay(1,"Check2");
    if (e.charCode==53) {
      gotoAndPlay(1,"Check3");
    if (e.charCode==54) {
      gotoAndPlay(1,"Scene2");
    if (e.charCode==55) {
      gotoAndPlay(1,"Scene1");

  • Can we catch keyboard event triggered by an inputfiled?

    Hi all,
    I have a question here:
    When we are doing the web dynpro abap development, if I want to catch the keyboard triggered by an
    input help and handle it, how can I achieve this?
    e.g.   I have an inputfield on the UI,  if user click "F10" on the keyboard, can I catch this kind of event?
    Thanks and Regards,
    Aaron

    Hi Thomas,
    Yes, I'm trying to acomplish an input help for an inputfield.But, the free programmed value or OVS or dictionary search help can fullfill my needs.Here is the situation:
    I have a inputfield on the UI, and next to that , I have another textview, which should be changed according inputfield. e.g.  the inputfield is a user name, and next to that , is the user id. but we only want the input help for user name. so when user select one row iof the search result table, I want that two fields both filled.
    1. the OVS can't meet my need because I can't change the layout of the search result table, I need a table with a tree in it.
    2. free programmed value help can only send back the value of the inputfield. although maybe I can get the user_id's context attribute name and by hardcoding and send back also the user id. but I don't like hardcoding.
    So, I'm wondering whether I could catch the keyboard event. and handle the F4 help all by myself.
    Do you have some suggestion on this?
    Thanks and Regards,
    Aaron

  • Getting keyboard events on ALV grid

    Hi,
    I have an ALV Grid where it is possible to edit data. If user selects a row and presses delete/cut button with mouse event is triggered and I can access those events in code. Although if user selects a row and presses "Del" or "Ctrl + X" then I can't access those events in code. Is there a way to access keyboard events inside my code?

    Have a look at BCALV_GRID_EDIT -> if you select the first checkbox (p_cell = Update on cell change) then you will find that "data_changed" event can catch the line deletion via the keystrokes described.. in the event in this program, you could get the rows deleted from "rr_data_changed->mt_deleted_rows".
    if p_cell = 'X'.
      call method grid1->register_edit_event
        exporting
          i_event_id = cl_gui_alv_grid=>mc_evt_modified.
    else.
    Jonathan

Maybe you are looking for