Looked in your file briefly. I don’t have a whole lot of feedback other than it’s very different than what I did in my capx.
I tried to move all the logic in the click function. Yours has it multiple places.
In mine it doesn’t refer to the mouse or touch at all in the click function. The idea is that function is called for every click xy. Can be modified for touch xy as stated in my previous reply.
Sounds like you may just want to record the keys instead. Just the time a key changes to pressed from not pressed and vise versa. You wouldn’t have to worry about recording input then and you’d have more freedom with using any input events you like.
Anyways, just some thoughts.