Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7685489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:15:45+00:00 2026-05-31T19:15:45+00:00

Here is what I’ve got so far.. I’m using this as a keybind. I

  • 0

Here is what I’ve got so far.. I’m using this as a keybind. I want to press the “Down” arrow key anytime the app is running, and then make it auto press the “Down” arrow key 3 extra times then finish by pressing “Enter” in the code. I know this isn’t the best explanation but sorry and I will try to explain it any better if you still didnt understand.

Here is the code:

public class MyKeyListener extends KeyAdapter{ 
@Override
public void keyPressed(KeyEvent evt){  
}

KeyListener keyListener = new KeyListener() {
    @Override
  public void keyPressed(KeyEvent keyEvent) {
    int keyCode = keyEvent.getKeyCode();
        if(keyCode == 1005){
        System.out.println("So far, so good..");
        }

  }

    @Override
    public void keyTyped(KeyEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void keyReleased(KeyEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

};

I think the Key arrow down is 1005.
I’ve so far wrote System.out.println(“So far, so good..”); to see if the app even detects it when I press the down arrow key, but it doesn’t…

Any ideas please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:15:46+00:00Added an answer on May 31, 2026 at 7:15 pm

    I’m just throwing this out there because I think it MAY be useful to you, this is a virtual Java keyboard, modified from some resource I found on the web years ago and which I no longer remember the link to:

    import java.awt.AWTException;
    import java.awt.Robot;
    import java.awt.event.KeyEvent;
    
    public class Keyboard {
    
    
        public void main (String[] args) throws InterruptedException {
            while(true) {
            type("
    
    ");
            }
        }
    
    
        private static Robot robot;
        static Random rand = new Random();
    
        public Keyboard() throws AWTException {
            this.robot = new Robot();
        }
        public Keyboard(Robot robot) {
            this.robot = robot;
        }
        public void type(CharSequence characters) throws InterruptedException {
            int length = characters.length();
            for (int i = 0; i < length; i++) {
                    char character = characters.charAt(i);
                    type(character);                
    
            }
    
             robot.keyPress(KeyEvent.VK_ENTER);
             robot.keyRelease(KeyEvent.VK_ENTER);
        }
    
        public void type(char character) {
            switch (character) {
            case 'a': doType(KeyEvent.VK_A); break;
            case 'b': doType(KeyEvent.VK_B); break;
            case 'c': doType(KeyEvent.VK_C); break;
            case 'd': doType(KeyEvent.VK_D); break;
            case 'e': doType(KeyEvent.VK_E); break;
            case 'f': doType(KeyEvent.VK_F); break;
            case 'g': doType(KeyEvent.VK_G); break;
            case 'h': doType(KeyEvent.VK_H); break;
            case 'i': doType(KeyEvent.VK_I); break;
            case 'j': doType(KeyEvent.VK_J); break;
            case 'k': doType(KeyEvent.VK_K); break;
            case 'l': doType(KeyEvent.VK_L); break;
            case 'm': doType(KeyEvent.VK_M); break;
            case 'n': doType(KeyEvent.VK_N); break;
            case 'o': doType(KeyEvent.VK_O); break;
            case 'p': doType(KeyEvent.VK_P); break;
            case 'q': doType(KeyEvent.VK_Q); break;
            case 'r': doType(KeyEvent.VK_R); break;
            case 's': doType(KeyEvent.VK_S); break;
            case 't': doType(KeyEvent.VK_T); break;
            case 'u': doType(KeyEvent.VK_U); break;
            case 'v': doType(KeyEvent.VK_V); break;
            case 'w': doType(KeyEvent.VK_W); break;
            case 'x': doType(KeyEvent.VK_X); break;
            case 'y': doType(KeyEvent.VK_Y); break;
            case 'z': doType(KeyEvent.VK_Z); break;
            case 'A': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_A); break;
            case 'B': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_B); break;
            case 'C': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_C); break;
            case 'D': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_D); break;
            case 'E': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_E); break;
            case 'F': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_F); break;
            case 'G': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_G); break;
            case 'H': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_H); break;
            case 'I': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_I); break;
            case 'J': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_J); break;
            case 'K': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_K); break;
            case 'L': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_L); break;
            case 'M': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_M); break;
            case 'N': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_N); break;
            case 'O': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_O); break;
            case 'P': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_P); break;
            case 'Q': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_Q); break;
            case 'R': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_R); break;
            case 'S': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_S); break;
            case 'T': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_T); break;
            case 'U': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_U); break;
            case 'V': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_V); break;
            case 'W': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_W); break;
            case 'X': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_X); break;
            case 'Y': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_Y); break;
            case 'Z': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_Z); break;
            case '`': doType(KeyEvent.VK_BACK_QUOTE); break;
            case '0': doType(KeyEvent.VK_0); break;
            case '1': doType(KeyEvent.VK_1); break;
            case '2': doType(KeyEvent.VK_2); break;
            case '3': doType(KeyEvent.VK_3); break;
            case '4': doType(KeyEvent.VK_4); break;
            case '5': doType(KeyEvent.VK_5); break;
            case '6': doType(KeyEvent.VK_6); break;
            case '7': doType(KeyEvent.VK_7); break;
            case '8': doType(KeyEvent.VK_8); break;
            case '9': doType(KeyEvent.VK_9); break;
            case '-': doType(KeyEvent.VK_MINUS); break;
            case '=': doType(KeyEvent.VK_EQUALS); break;
            case '~': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_QUOTE); break;
            case '!': doType(KeyEvent.VK_EXCLAMATION_MARK); break;
            case '@': doType(KeyEvent.VK_AT); break;
            case '#': doType(KeyEvent.VK_NUMBER_SIGN); break;
            case '$': doType(KeyEvent.VK_DOLLAR); break;
            case '%': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_5); break;
            case '^': doType(KeyEvent.VK_CIRCUMFLEX); break;
            case '&': doType(KeyEvent.VK_AMPERSAND); break;
            case '*': doType(KeyEvent.VK_ASTERISK); break;
            case '(': doType(KeyEvent.VK_LEFT_PARENTHESIS); break;
            case ')': doType(KeyEvent.VK_RIGHT_PARENTHESIS); break;
            case '_': doType(KeyEvent.VK_UNDERSCORE); break;
            case '+': doType(KeyEvent.VK_PLUS); break;
            case '\t': doType(KeyEvent.VK_TAB); break;
            case '\n': doType(KeyEvent.VK_ENTER); break;
            case '[': doType(KeyEvent.VK_OPEN_BRACKET); break;
            case ']': doType(KeyEvent.VK_CLOSE_BRACKET); break;
            case '\\': doType(KeyEvent.VK_BACK_SLASH); break;
            case '{': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_OPEN_BRACKET); break;
            case '}': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_CLOSE_BRACKET); break;
            case '|': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_SLASH); break;
            case ';': doType(KeyEvent.VK_SEMICOLON); break;
            case ':': doType(KeyEvent.VK_COLON); break;
            case '\'': doType(KeyEvent.VK_QUOTE); break;
            case '"': doType(KeyEvent.VK_QUOTEDBL); break;
            case ',': doType(KeyEvent.VK_COMMA); break;
            case '<': doType(KeyEvent.VK_LESS); break;
            case '.': doType(KeyEvent.VK_PERIOD); break;
            case '>': doType(KeyEvent.VK_GREATER); break;
            case '/': doType(KeyEvent.VK_SLASH); break;
            case '?': doType(KeyEvent.VK_SHIFT, KeyEvent.VK_SLASH); break;
            case ' ': doType(KeyEvent.VK_SPACE); break;
            default:
                    throw new IllegalArgumentException("Cannot type character " + character);
            }
        }
    
        private static void doType(int... keyCodes) {
            doType(keyCodes, 0, keyCodes.length);
        }
    
        private static void doType(int[] keyCodes, int offset, int length) {
            if (length == 0) {
                    return;
            }
    
            robot.keyPress(keyCodes[offset]);
            doType(keyCodes, offset + 1, length - 1);
            robot.keyRelease(keyCodes[offset]);
        }
    
    }
    

    To modify this to your needs, you would do:

    for(int i = 0; i != 3; ++i) {
    doType(KeyEvent.VK_DOWN);
    }
    

    The doType(KeyEvent.VK_DOWN); would press down one time, and then also release it.

    You would probably insert that after the “So far, so good…” part in your code.

    Hope I helped!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
Here's what I'm trying to accomplish with this program: a recursive method that checks
here is my configuration: http://domain.com (obviously fictitious name...) hosted on a server running Apache
Here is the css: #content ul { font-size: 12px; } I am trying this:
Here my problem: @Assert\Regex( * pattern=/^[A-Za-z0-9][A-Za-z0-9\]*$/, * groups={creation, creation_logged} * ) I'm using the
Here's my situation. I have a DotNetNuke application. I want to link to an
here is what I want to do: Add a CALayer as a sublayer to
Here is my code...I have two dimensional matrices A,B. I want to develop the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.