Holding a number key button down for a few seconds

Asked by Alsabit Siyyid on 2020-05-04

Hello, for my particular software, I need to hold down the "1" key for at least 3 seconds to form a binding and save a new view of the screen. I tried the following code to do this:


When I do that, Sikuli functions as if I simply pressed the button once as opposed to actually holding down the button for 5 seconds.
I've even added other mouseMove commands in between the key commands to see if that made a difference but it did not. Do you know how I could solve this issue?

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
masuo (masuo-ohara) said : #1
Alsabit Siyyid (asiyyid) said : #2


Thanks. I tried all the things mentioned in that post aside from running sikuli as an administrator. I am still not getting the desired outcome. Manually, I hold down "1" for a few seconds, a sounds happens, and then the key is binded. But no matter what I try with sikuli, the outcome is as if I press it once and immediately let go as oppose to holding it down.

Is there any other way or code I can try out to get the outcome I desire?

masuo (masuo-ohara) said : #3

see #1 answer

RaiMan answered the question as follows:
keyDown() does not trigger the keyboard repeat function (Java Robot)

Alsabit Siyyid (asiyyid) said : #4


So theres no way to trigger the keyboard repeat function?

Alsabit Siyyid (asiyyid) said : #5


I've even tried the for loop method he recommended but that doesnt seem to work either.

RaiMan (raimund-hocke) said : #6

as mentioned in the other question:
keyDown in SikuliX (Java Robot) does not trigger the key repeat feature (works only if keyboard is used manually)

this repeatedly types the given key:

for n in range(10):

for n in range(10):

where the second version types a bit faster.

Alsabit Siyyid (asiyyid) said : #7


Thank you for the response. So just to make sure I am understanding correctly, there is nothing in SikuliX that can automate a key repeat feature? That feature can only work manually when SikuliX is not actually being run?

RaiMan (raimund-hocke) said : #8

- it only works when using the real keyboard (manual typing)
- does not matter, wether SikuliX runs or not
- SikuliX's current features cannot do it

Can you help with this problem?

Provide an answer of your own, or ask Alsabit Siyyid for more information if necessary.

To post a message you must log in.