So I’m still struggling with this…
The solution above works for almost all scenarios when typing normally, because by setting the kKeyTimeoutInSeconds value to a very low number (ie 0.01), it fires the “fake” key up / release event almost immediately after the key down / press event, which resets the key and allows it to be pressed again.
Additionally, if the key is held down, because the fake key up / release event has been fired immediately after the key down event, the key will keep firing the press / release cycle over and over.
For some instances (like holding down the back space key for example) this may create the desired outcome.
But the one situation I can’t for the life of me figure out how to work around is holding down a key and then releasing it a little while later and telling the difference between the fake release / key up events that are being fired after kKeyTimeoutInSeconds has passed and my real key up event when I actually take my finger off the key.
This is important in my situation, because I’m wanting to something to occur when the user pressed a particular key (the shift key in my case) and something else to occur when they release the key for real.
The problem is that by the time they release the key for real, the app thinks it’s already been released because a fake release event occurred after kKeyTimeoutInSeconds and that event is indistinguishable from a real key release by the user.
I’ve tried absolutely everything I can think of. New input system, old input system, checking onGUI events, in the Update loop, combining both, checking at the end of each frame, using a timer to check every n milliseconds. But because the fake release event is in no way distinguishable from a real, human-activated release event, the app thinks the key has been released when it hasn’t.
What is so frustrating is that running the app in the editor, the functionality works absolutely perfectly. It’s only once we transfer to an iPad that the issue occurs, so clearly it’s possible to handle keyboard input correctly and as expected.
As DemonStudios says, why on earth would you want to be forced to wait half a second by default to be able to use the same key twice in a row? And even if you did want to, why is there also no way of telling when a real key release event occurs.
Having some difference passed through for fake / real events would solve my issue as I could then ignore the fake events.
Unity - is there anything you can do on this, or is it an Apple thing that you have no control over?
Any advice / further thoughts (or if anyone has implemented a successful press / hold / release for the shift key whilst pressing another key at the same time to capitalise it, I would really appreciate knowing about it - as I say, I have it working perfectly in the editor, but on iOS I’m at a brick wall).
Thanks in advance!
Ian