Page 1 of 1

Macrobuttons System.KeyPress bug

Posted: Mon Jul 06, 2020 5:59 pm
by daccy
I'm using macrobuttons 1.0.3.1 and I think I've got a bug with System.KeyPress()

I have a button set up to do this in the Request for Button ON section:

Code: Select all

System.KeyPress("SHIFT+LEFT");
In my use case the button is triggered from a midi input, but that isn't necessary to reproduce this.

I'm monitoring system key events using this event viewer https://w3c.github.io/uievents/tools/ke ... iewer.html

and the problem I'm having is that the behaviour seems to be different depending on whether NumLock is on.

When NumLock is off and my button calls

Code: Select all

System.KeyPress("SHIFT+LEFT");
it does what I would expect...I get a keydown for Shift, then a keydown for ArrowLeft, then a keyup for ArrowLeft, then a keyup for Shift, all in that sequence.

When NumLock is on, I get a different sequence when my button calls

Code: Select all

System.KeyPress("SHIFT+LEFT");
I get a keydown for Shift, then a keyup for Shift, then a keydown for ArrowLeft, then a keyup for ArrowLeft, then a keydown for Shift.

A second press of my button, still with NumLock on, gives the following sequence: keyup for Shift, keydown for ArrowLeft, keyup for ArrowLeft then finally keydown for Shift.

So the effect is that the ArrowLeft is pressed in an unshifted state, and also Shift is left down at the end of the sequence (which can cause other problems until cancelled by pressing Shift again). That doesn't seem right!

Rewriting the button to use System.KeyDown() for each key individually in the ON section and System.KeyUp() for each key individually in the OFF section doesn't solve this because when NumLock is active I still get an unexpected keyup for Shift before the keydown for ArrowLeft (although the final System.KeyUp() for Shift does stop Shift from being left on).

Is this a bug?

Kind regards,
Andrew

Re: Macrobuttons System.KeyPress bug

Posted: Mon May 02, 2022 5:51 pm
by mickboot
Hey, I know this is a pretty old post but I was facing the same issue, and you helped me figure out that numlock is involved in this somehow.

So, what I just did is add System.KeyPress("numlock") before and after my shift+right request, and that did the trick!

Thanks to you for helping me figure out an easy solution, and I hope this might help others facing the same issue.