Capture Key events

I am trying to create a program to capture key events, regardless of where the focus is. For example, any time the user presses ctrl-t, I would like to call a particular method, if the user is in Microsoft Word, Internet Explorer, Halo, or any other application. However, a glass pane would not work, because all other key events will be needed by the current application. This would be identical to Microsoft' s ctrl-alt-del and Microsoft's alt-tab. Any ideas would be greatly appriciated. Post here or E-mail be at [email protected]

This is not true, think of all the keylogger programs out there that allow you to do this.
It's not a security issue.
I also am wondering how to capture a key on a java application without it having focus. An example is a timer in a game. I should be able to be in a full screen game and hit F1 or Home or whatever I choose and have a timer start that will ding at me in 1 minute to let me know that my time is up.
It is in a way similar to CTRL ALT DEL in that you don't ahve to be focused on anything in particular to use it but that isn't really the best analogy.
If anyone can point me in the right direction to figure out how I would go about this, please tell me. Or if it is not possible for a program written in java to capture keypress without focus I would like to know that as well.
You can do this in C and C++ but I would like to just add it in to an existing java program, thanks.

Similar Messages

  • Can't capture key event in applet

    Hi,
    Currently i'm developing an applet. However, i fail to capture the key event in the applet. The key that i fail to capture is VK_TAB. Any idea to handle this?
    Thanks in advance!

    to capture key event, u need to
    1. addKeyListener
    2. focus on that component (yourApplet must focusable)

  • Capture Key Event - Feature Request

    Hello,
    We are using Forms 9.0.4 to build applications to be viewed over our intranet using Jinitiator. I am new to the development team and this is my first time using Forms. I am trying to find a way to capture key press events on a given field (we want to automatically search within a field each time the user enters a letter). I have seen nothing inherent in Forms to do this. There has been lots of metion of a PJC.
    1. Is there a plan to include such a trigger by default?
    2. If not, can someone please dumb-down PJCs for me?
    Thanks,
    ~Rob Lundeen

    yesterday in how to find which key the user presses we had a solution :
    http://www.oracle.com/technology/sample_code/products/forms/distributions/keyfilter.zip
    thx to indusvalley

  • Capture desktop key event to control my screen capture app

    I want to write a screen capture program to capture screen when I am playing fullscreen game or other desktop window application. But the java screen capture program can only receive key or mouse event when it is focused. So how do I capture key event when I am focusing other app or fullscreen app?
    Do I have to use JNI and call some OS specific API. My target OS is WinXP. Help or suggestions are appreciated!!

    Hi All,
    I was wondering if there is a way to capture the top-most
    window or dialog box. This is something that will
    generally be running outside of the JVM....We,
    as programmers, need a Rectangle instance that describes the area
    of interest to be captured (i.e., location and size).
    Thus, a routine that interfaces to the Native windowing system (Toolkit?)
    might look something like:
    Rectangle rect = tk.getRectangleForTopMostComponent();
    Does anything like this exist?
    Thanks!
    - DocJava

  • Capturing Enter key event from text box

    In my application, there are a number of text boxes. I want to create a feature where an enter key even is seen and specific function executed depending on which text box was in focus when the enter key was pressed. Currently I am able to capture an enter key event on the whole page. How do I do that specifically for a text box?
    This application is done in HTML, javascript and Adobe AIR.
    Thanks
    Binu
    www.verseview.info

    Hi
    That's true that Flex4.5 SDK under Flash builder Burito doesn't listen Enter key in Text Area for KeyUp or KeyDown event.
    Here I found a work around you can use.
    Add an eventlistener to the component in actionscript and set the useCapture=true next to eventlistener function. Now you can listen enter key for KeyUp or KeyDown Event
    Hope this helps
    Rush-me

  • KeyListener does not capture Arrow key Events in textField

    Love................
    I added a key listener to TextField it does not detect
    Arrow Keys events in keyTyped, KeyPressed,KeyReleased methods
    why?????
    I want to shift focus from a textfield to other component
    on capturing Arrow key Pressed How

    Here is a Java demo where it works since it is not a printable character you must get the keyCode:
    http://java.sun.com/docs/books/tutorial/uiswing/events/example-swing/index.html#KeyEventDemo
    public class KeyEventDemo ... implements KeyListener ... {
    ...//where initialization occurs:
         typingArea = new JTextField(20);
         typingArea.addKeyListener(this);
    /** Handle the key typed event from the text field. */
    public void keyTyped(KeyEvent e) {
         displayInfo(e, "KEY TYPED: ");
    /** Handle the key pressed event from the text field. */
    public void keyPressed(KeyEvent e) {
         displayInfo(e, "KEY PRESSED: ");
    /** Handle the key released event from the text field. */
    public void keyReleased(KeyEvent e) {
         displayInfo(e, "KEY RELEASED: ");
    protected void displayInfo(KeyEvent e, String s){
         char c = e.getKeyChar();
         int keyCode = e.getKeyCode();
         int modifiers = e.getModifiers();
         tmpString = KeyEvent.getKeyModifiersText(modifiers);
         ...//display information about the KeyEvent...
    }

  • How to capture backspave and delete key events

    Hi ,
    i would like perform some javascript code on pressing backspace or delete key.
    initially i thought of adf clientlsitener keypress event.but this is not capturing backsapce key event
    what is the alternate way capture backspace or delete key event?
    please help

    Hi
    the following script cancels the input event when the back key is pressed
           function keyTrap(inputEvent){
             var keycode = inputEvent.getKeyCode();
             if(keycode ==8){
               inputEvent.cancel();
           }Use a clientListener
            <af:inputText label="Label 4" id="it7">
              <af:clientListener method="keyTrap" type="keyDown"/>
            </af:inputText>Frank

  • Capturing the TAB key event.

    How can I capture the TAB key event?
    I am trying to use it within a JTextField to do a normal text tab operation.
    Thanks,
    D

    I want to map the Tab key to a jTextField so that when the user is editing inside the jTextField they can press the TAB key to tab over a predefined number of characters.
    Thanks,
    D

  • Capture key and mouse event

    Hi,
    What I want to do is..
    when users click on a item such as text item and press the 'Ctrl' key, a message will
    appear.
    How can I capture the event ?
    Thanks.
    Ivan

    Duplicate thread. Please see the other one at:
    <p>capture key and mouse event

  • Capture 'Enter' key event

    Hi,
    Is there any way we can capture the event when a user presses the enter key inside a text field?

    Hi andrewquay
    you can capture the enter key by adding the following code in the textfield's change event.
    if(xfa.event.change == "\u000a")
    xfa.host.messageBox("enter key is pressed");
    mail: [email protected]

  • Key event capture

    I can't find a way to capture the key events of the special key on multimedia keyboards, just like play/pause, browser or music..
    Any ideas?

    You probably can't. They have their own drivers to handle those specialties and Java (as far as I know) doesn't have support for those.

  • How to capture the event in ALV grid display?

    Hi experts,
      How to capture the event in an ALV grid display which is editable. I have to capture the TAB key or ENTER key.
    regards,
    Arul Jothi.

    Hi Arul,
    Take a look at sample program BCALV_EDIT_03. (Find string "register ENTER" in the program to see how to register)
    Basically you have to Register edit events using method call REGISTER_EDIT_EVENT and then write a handler method for event DATA_CHANGED..
    If you are using a REUSE..GRID fm then first get the grid reference using function module GET_GLOBALS_FROM_SLVC_FULLSCR and then repeat the above procedure..
    Hope this helps..
    Sri
    Message was edited by: Srikanth Pinnamaneni

  • Handling 'enter key' event in alv using classes

    Hello all,
        i have a scenario where i have a grid from which i have to select a row and press 'enter' key, then the row would be added to grid on top of it. we have developed this grids using control and classes.
        please any one tell me how would i get the enter key code.
    Thanks,
    krishnam raju N

    HI Raju
    just go through these
    check the sample program.
    <b>BALV_POPUP_TO_SELECT
    ENTER is nothing but selecting the record.
    </b>
    Re: ALV  'ENTER' key
    and go through this code
    constants :
    C_PF_STATUS TYPE SLIS_FORMNAME VALUE 'F_SET_PF_STATUS'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = V_REPID
    I_CALLBACK_PF_STATUS_SET = C_PF_STATUS
    I_CALLBACK_USER_COMMAND = P_USER_COMMAND IS_LAYOUT = WA_LAYOUT
    IT_FIELDCAT = IT_FIELDCAT[]
    IT_EXCLUDING = IT_EXTAB[]
    IT_SORT = IT_SORT[]
    TABLES
    T_OUTTAB = P_ZBCAR50
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2.
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    2.
    *& Form F_SET_PF_STATUS
    Set PF_STATUS STANDARD modifying the standard toolbar
    by excluding some buttons
    -->P_IT_EXTAB -- TABLE OF EXCLUDING FUNCTIONS
    FORM F_SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
    CLEAR : WA_EXTAB,
    IT_EXTAB.
    *--Set the Modified PF status for the ALV.
    SET PF-STATUS 'STATUS_01' EXCLUDING RT_EXTAB.
    ENDFORM. " SET_PF_STATUS
    3.
    *& Form f_user_command
    Handle user action on ALV toolbar
    FORM F_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
    DATA : L_ANSWER TYPE C.
    RS_SELFIELD-REFRESH = C_X.
    IF R_UCOMM = 'ENTR'.
    Do your processing here.
    ENDIF
    and go through these links
    <b>how to identify pressing ENTER on ALV
    How to capture the event in ALV grid display?
    Re: ALV-Grid: No reaction to Enter-Button
    </b>
    IF IT HELPS REWARD WITH POINTS
    Regards Rk
    Message was edited by:
            Rk Pasupuleti

  • Sap  business One (capture control events)

    How do I capture keyboard events(especially those with Control like CTRL-R) in SBO??

    Hi Payal,
    You can catch the key down event in your Item_Event handler as follows:
    If pVal.Modifiers = SAPbouiCOM.BoModifiersEnum.mt_CTRL And pVal.CharPressed = 82 Then
        'do something
    End If
    Hope it helps,
    Adele

  • Key events on the glasspane

    I'm trying to develop a glasspane that captures the key events as well as the mouse events.. In this example, the mouse events happen exactly the way I want them to, but I cannot for the life of me get a key event to register.. I've tried capturing keyTyped(), keyPressed(), and keyReleased() to no avail.. Dukes to whoever shows me the light,
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class BCInv
        extends JFrame {
      JScrollPane jScrollPane1 = new JScrollPane();
      JTextArea jTextArea1 = new JTextArea();
      JScrollPane jScrollPane2 = new JScrollPane();
      JTable jTable1 = new JTable();
      JButton jButton1 = new JButton();
      public BCInv() {
        jbInit();
        setVisible(true);
        getGlassPane().setVisible(true);
        //here I'm adding both listeners in the same manner
        getGlassPane().addMouseListener(new BCInv_mouseAdapter());
        getGlassPane().addKeyListener(new BCInv_keyAdapter());
      public void jbInit() {
        setSize(new Dimension(611, 423));
        getContentPane().setLayout(null);
        jScrollPane1.setBounds(new Rectangle(9, 275, 574, 110));
        jTextArea1.setText("jTextArea1");
        jScrollPane2.setBounds(new Rectangle(10, 13, 573, 175));
        jButton1.setBounds(new Rectangle(196, 217, 89, 42));
        jButton1.setText("jButton1");
        this.getContentPane().add(jScrollPane1, null);
        this.getContentPane().add(jScrollPane2, null);
        this.getContentPane().add(jButton1, null);
        jScrollPane2.getViewport().add(jTable1, null);
        jScrollPane1.getViewport().add(jTextArea1, null);
      public static void main(String[] args) {
        BCInv BC = new BCInv();
      //this key stuff here never executes..
      void BCkey(KeyEvent e) {
        System.out.println("A key was typed: '"+e.getKeyChar()+"' = "+e.getKeyCode());
      class BCInv_keyAdapter extends java.awt.event.KeyAdapter {
        BCInv_keyAdapter() {}
        public void keyTyped(KeyEvent e) {
          BCkey(e);
      //All this mouse stuff works great..
      void BCmouseClicked(MouseEvent e) {
        System.out.println("click");
        Point glassPanePoint = e.getPoint();
        boolean inButton = false;
        boolean inMenuBar = false;
        Component component = null;
        Container container = getContentPane();
        Point containerPoint = SwingUtilities.convertPoint(
            getGlassPane(),
            glassPanePoint,
            getContentPane());
        component = SwingUtilities.getDeepestComponentAt(
            container,
            containerPoint.x,
            containerPoint.y);
        if (component == null) {
          return;
        System.out.println("underlying component="+component.toString());
      class BCInv_mouseAdapter
          extends java.awt.event.MouseAdapter {
        BCInv_mouseAdapter() {}
        public void mouseClicked(MouseEvent e) {
          BCmouseClicked(e);
    }

    * @author nordj
    public class GlassPane extends JPanel {
         private boolean okToLooseFocus = true;
         public GlassPane() {
              setName("GlassPane");
              setVisible(false);
              super.setOpaque(false);
              //super.setBackground(new Color(0x00,0x00,0x00,0x88));
              //super.setForeground(new Color(0x00,0x00,0x00,0xFF));
              // trap keyboard & mouse events.
              //enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
              enableEvents(0xFFFFFFFFFFFFFFFFl);
              setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
              setInputVerifier(new GlassPaneInputVerifier());
         /* (non-Javadoc)
          * @see java.awt.Component#processMouseEvent(java.awt.event.MouseEvent)
         protected void processMouseEvent(MouseEvent e) {
              if (e.getID() == e.MOUSE_CLICKED) {
                   Toolkit.getDefaultToolkit().beep();
                   e.consume();
              super.processMouseEvent(e);
         /* (non-Javadoc)
          * @see java.awt.Component#processKeyEvent(java.awt.event.KeyEvent)
         protected void processKeyEvent(KeyEvent e) {
              Toolkit.getDefaultToolkit().beep();
              super.processKeyEvent(e);
         /* (non-Javadoc)
          * @see java.awt.Component#processEvent(java.awt.AWTEvent)
         protected void processEvent(AWTEvent e) {
              // TODO Auto-generated method stub
              //System.err.println(e);
              super.processEvent(e);
         /* (non-Javadoc)
          * @see java.awt.Component#setVisible(boolean)
         public void setVisible(boolean visible) {
              okToLooseFocus = !visible;
              super.setVisible(visible);
              if (visible) {
                   requestFocusInWindow();
         /* (non-Javadoc)
          * @see java.awt.Component#paint(java.awt.Graphics)
         public void paint(Graphics g) {
              g.setColor(new Color(0xFF,0x00,0x00,0x88));
              g.fillRect(0,0,getWidth(), getHeight());
          * Simple hack to stop the RootPane loosing focus when it's visible
          * @author nordj
         private class GlassPaneInputVerifier extends InputVerifier {
              /* (non-Javadoc)
               * @see javax.swing.InputVerifier#verify(javax.swing.JComponent)
              public boolean verify(JComponent input) {
                   //return (!isVisible());
                   return okToLooseFocus;
    }

Maybe you are looking for

  • Removed layouts folder but still "Restoring the window layout"

    MY ORIGINAL PROBLEM All my Final Cut Pro X files are save on my external hard drive. When I open FCP with my hard drive plugged in, FCP says "Restoring the window layout" and a grey background appears. If I open FCP without my harddrive and then plug

  • Snapshot failed error

    Has anyone got a snapshot fail error in Device Central CS4? Any ideas on how to resolve it? The error I get is - "SNERR: Snapshot failed at 08:34:27 PM - pool capacity too low". I got this while testing a Flash Lite game on the Nokia 5800 in Device C

  • Udev rules problem (2 webcams, assigning videoX devices)

    I've got a built-in webcam (notebook) and an external one connected too, different vendor/product IDs. I want the built-in cam to be video0 and the external one video1. I added a file /etc/udev/rules.d/25-name-video-devices.rules containing: #externa

  • The OS installed Vietnamese language instead of English

    I have been very frustrated because every time I tried to upgrade the OS on my MacBook Air, it installed in Vietnamese instead of English.  May be because I have Vietnamese name? I would be stupid for the OS to assume loading the OS in the language t

  • Safari unable to access server error message on ipad

    wireless network connected to Ipad but Safari "unable to connect to server" at any web address entered