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 706913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:13:08+00:00 2026-05-14T04:13:08+00:00

There seems to be an issue simulating the backspace key with java.awt.Robot . This

  • 0

There seems to be an issue simulating the backspace key with java.awt.Robot.

This thread seems to confirm this but it does not propose a solution.

This works:

Robot rob = new Robot();
rob.keyPress(KeyEvent.VK_A);
rob.keyRelease(KeyEvent.VK_A);

This doesn’t:

Robot rob = new Robot();
rob.keyPress(KeyEvent.VK_BACK_SPACE);
rob.keyRelease(KeyEvent.VK_BACK_SPACE);

Any ideas?

  • 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-14T04:13:08+00:00Added an answer on May 14, 2026 at 4:13 am

    It seems to work in this test.

    Addendum: Regarding the cited article, “Aside from those keys that are defined by the Java language (VK_ENTER, VK_BACK_SPACE, and VK_TAB), do not rely on the values of the VK_ constants. Sun reserves the right to change these values as needed to accomodate a wider range of keyboards in the future.”—java.awt.event.KeyEvent

    public class RobotTest {
    
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new RobotTest().create();
                }
            });
        }
    
        private void create() {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setLocationRelativeTo(null);
            f.setLayout(new FlowLayout());
            f.add(new JTextField(8));
            final JButton b = new JButton();
            f.getRootPane().setDefaultButton(b);
            b.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    b.setText("@" + e.getWhen());
                }
            });
            f.add(b);
            f.setSize(256, 128);
            f.setVisible(true);
            doTest();
        }
    
        private void doTest() {
            try {
                Robot r = new Robot();
                int[] keys = {
                    KeyEvent.VK_T, KeyEvent.VK_E,
                    KeyEvent.VK_S, KeyEvent.VK_T,
                    KeyEvent.VK_Z, KeyEvent.VK_BACK_SPACE,
                    KeyEvent.VK_ENTER
                };
                for (int code : keys) {
                    r.keyPress(code);
                    r.keyRelease(code);
                }
            } catch (AWTException ex) {
                ex.printStackTrace(System.err);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This query is not returning any result as there seems to be an issue
There seems to be a similar question to this on here but with the
I've been searching on how to solve this issue but could not find any
This may be waaay to specific for SO, but there seems to be a
I'm writing a mobile app in PhoneGap, but there seems to be an issue
I made my own little tooltip, but there seems to be an issue when
In my app after a while, there seems to be a huge issue. There
There seems to be an issue around generating IDs with indexers within the MVC
So there seems to be an issue with animating size transformations for UIButtons. Specifically,
On iPad Safari, there seems to be issue with popup. When a popup (opened

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.