Simulate a key held down in Java

前端 未结 3 1510
暗喜
暗喜 2020-12-03 19:50

I\'m looking to simulate the action of holding a keyboard key down for a short period of time in Java. I would expect the following code to hold down the A key for 5 seconds

3条回答
  •  鱼传尺愫
    2020-12-03 20:24

    There is no keyDown event in java.lang.Robot. I tried this on my computer (testing on a console under linux instead of with notepad) and it worked, producing a string of a's. Perhaps this is just a problem with NotePad?

提交回复
热议问题