11-25-2022, 06:28 PM
(11-24-2022, 05:35 PM)King Mocker Wrote: Just curious,,doesn't _Keyhit use the same key press repeat delay that Inkey$ uses?
So, why use this in place of k=ucase$(inkey$)? Apart from the cool looking code.
Basic answer: numbers are faster than strings.
k isn't = ucase$(inkey$) as you assert above.
You'd need k = ASC(ucase$(inkey$)) to come close to the right answer. (I say CLOSE, because it doesn't deal with extended inkey$ values, such as the arrow keys.)
A true equivalent would be:
Code: (Select All)
Do
k = _KeyHit
i$ = InKey$
If i$ <> "" Then
If Len(i$) = 1 Then i$ = i$ + Chr$(0)
k1 = CVI(i$)
Else
k1 = 0
End If
If k Then Print k, k1
_Limit 30
Loop Until k = 27
If you run the above, you'll see there's STILL a difference between the _keyhit value and what we've translated for our inkey$ value -- _KEYHIT can give us both an UP and DOWN code, while INKEY$ just tells us when a key is pressed DOWN.
^ And that's the differences in the two in a nutshell.