![]() |
|
Don't let INKEY$ byte you in the ASCII - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: Chatting and Socializing (https://qb64phoenix.com/forum/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://qb64phoenix.com/forum/forumdisplay.php?fid=2) +--- Thread: Don't let INKEY$ byte you in the ASCII (/showthread.php?tid=4439) |
Don't let INKEY$ byte you in the ASCII - Pete - 02-01-2026 I mostly love INKEY$, but we can't rely on it to accurately report a key was not released. So here are some observations. The last example is a Combined Inkey$ and _Keyhit solution. Hold down the "A" key and don't release it. See, INKEY$ says it was released! Code: (Select All)
Now a jerkaround is to add a delay. This works, but sucks... Code: (Select All)
That's right. At least in my system anything less than a half-second delay fails! Imagine typing with a half-second delay. So to ease the delay situation, we create a mock buffer and time it. (This is what I had to do before QB64). Code: (Select All)
I know, I know. I didn't bother to dim the array (buffer), so it will fail after 10 here, and I didn't bother to do a complete 24-hour timer, so it would fail once at mid-night, but I'm keeping it as simple coded as possible for this discussion. Anyway, all this crap can be avoided using the _KeyHit method or by adding _KeyHit to the Inkey$ routine. _KeyHit Method Code: (Select All)
And finally, our combined INKEY$ with _KEYHIT solution... _KeyHit used with Inkey$ Method Code: (Select All)
Just some food for thought for anyone who will need to monitor a key release like a same key tapping routine. Pete RE: Don't let INKEY$ byte you in the ASCII - PhilOfPerth - 02-01-2026 Nice one, @Pete. Compact and simple. I'll be adapting the clumsy "Response" in my programmes with this. Thanks. |