As I was discussing over at the Discord channels, here's a little tidbit about our key codes which a lot of people seem unaware of -- INKEY$ and _KEYHIT are the
EXACT same codes! The only difference is INKEY converts the codes to string format, while _KEYHIT keeps them as integer values.
To illustrate this, have fun pressing and holding keys down on your keyboard with the following code:
Print "INKEY$ = NULL";
" or ERROR" Print "_KEYHIT = "; k;
" or "; k
Mod 256; k \
256
If we use CVI (the QB64 command to convert a 2-byte string to an integer value) on INKEY$, we can see what values it gives us for any key pressed.
We can then compare those values to what KEYHIT gives us...
And, you guys might not believe this....
They're the *EXACT* same values.
There's
no difference between INKEY$ and _KEYHIT except for the rather obvious one -- one returns the value as a 2-byte string while the other returns the value as a 2-byte integer.
At their root, the only real difference between them is one is basically STR$(keycode) while the other is simply the VAL(keycode).
NOTE: (Actually it's a MKI$(keycode), but a lot of people are unfamiliar with converting numbers to strings with the MK$ commands, so I used STR$ in the previous sentence as *EVEYONE* tends to learn STR and VAL as some of their first commands with the language to help them highlight the difference between the INKEY$ values and KEYHIT values.)