mIRC Home    About    Download    Register    News    Help

Print Thread
on keydown triggering time when holding key #270062 23/03/22 07:35 PM
Joined: Jul 2006
Posts: 3,880
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,880
Code
;window -pfdfoC +l @win -1 -1 400 400
on *:keydown:@win:*:{
  echo -sg $ticksqpc $keyrpt
}
When I hold a key, I get:
Quote
767726441 $false
767726941 $true
767726973 $true
767727006 $true
767727039 $true
There is a significant gap between the first and the second time the key are reported by the event. This is not wanted and I don't believe this is intended, when you use this to animate an object from keypress, it results in one movement, then a significant pause, and then it goes normal. Could this be fixed? The second trigger always reports $keyrpt = $true, I'm unsure if it's related, I wouldn't mind getting the event to report a few of keypress with $keyrpt = $false before getting it to be $true.

Re: on keydown triggering time when holding key [Re: Wims] #270063 23/03/22 07:59 PM
Joined: Aug 2003
Posts: 303
P
Protopia Offline
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 303
Whilst I do understand the underlying requirement, isn't this how keyboards repeats are supposed to work - a longer pause before the first repeat then for subsequent repeats. If you hold a key down in e.g. Microsoft Word, isn't this how the repeat works?

Re: on keydown triggering time when holding key [Re: Protopia] #270065 24/03/22 12:26 PM
Joined: Jan 2004
Posts: 1,745
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,745
That's what I thought at first, but if you go to controlpanel/keyboard - or wherever it is that Win10 hides the setting, there's 2 settings for key board repeats, there's 1 setting for how fast the repeat itself happens, but there's another setting with 4 levels that governs how long is the delay between the 1st letter and the 1st repeat. Even when you change that to the fastest level, it's still a longer pause then between the other letters. Whether the OS won't let this be as short as the other intervals, I dunno.

Re: on keydown triggering time when holding key [Re: Protopia] #270066 24/03/22 04:14 PM
Joined: Jul 2006
Posts: 3,880
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,880
Yes, after a quick discussion on IRC, it's what it seems to be. In fact I was already aware of this behavior in the past, the solution is to handle the movement/keys/input inside an alias called by a timer infinitely. That way you can handle the key press at a regular interval. When writing simple stuff or writing proof of concept, you often end up updating coordinates from the event sadly.