user2999870
user2999870

Reputation: 375

How do I fix my computer key configuration after using robot.keyPress()?

I have been using the java.awt.Robot class (especially pressKey() method) in my code. However, once my code terminates, my keys get reconfigured. In my case, I had robot press Ctrl and R. Afterwards, my key functions for Start and Escape switched roles. And that was just one of several switches.

What is the fix to this?

Any help would be appreciated. Thank you.

Upvotes: 1

Views: 55

Answers (1)

keval choudhary
keval choudhary

Reputation: 62

This is because this function only press the key and not release it. You must call robot.keyRelease(); once after calling keypress() or call it for all the keys when closing the application.

Upvotes: 1

Related Questions