Still digesting this, but it does look like the Best Answer was pointed right.
Not sure how one goes about decoding key numbers for use in code. It's interesting that Mouse clicks can be detected also, and how is that decoded for use in code?
If you run it, you’ll see that I tried to map the keys to match the KEYHIT codes for a standard US Keyboard, as much as possible, so you can use those values for primary reference.
Now, some keys aren’t mapped to KEYHIT codes, simply because there’s no default KEYHIT value for them. (Such as the PLAY, BACK, FORWARD, or STOP buttons on keyboards that have those extra keys.) *ANY* key that Microsoft can read from a specialized keyboard
should be able to be read by the program — and I gave them a default value of starting with 900000+. If you look at the DATA statements, you can tell from them which keys they should normally map to:
' Index Unmodified Ctrl Shift Alt AltGr Repeat
DATA 176,900176,0,0,0,0,0.2: 'Media Next
DATA 177,900177,0,0,0,0,0.2: 'Media prev
DATA 178,900178,0,0,0,0,0.2: 'Media stop
DATA 179,900179,0,0,0,0,0.2: 'Media Play/Pause
DATA 180,900180,0,0,0,0,0.2: 'Launch mail
DATA 181,900181,0,0,0,0,0.2: 'Launch media select
DATA 182,900182,0,0,0,0,0.2: 'Launch app1
DATA 183,900183,0,0,0,0,0.2: 'Launch app2
Media Play/Pause button will return a default value of 900179. Next button is default 900176. If your keyboard has a MAIL button, its value will be 900180. (Unless you remap those values for your own needs/keyboards, which might be different according to your region/language, that is...)
Now, some keyboards have a mouse built in, and as such, we detect mouse buttons as extended input events as well. (Values around 900005, or so, if I remember correctly.)
If you wanted to, you could use the input routine to either accept, or ignore those extended key events:
k = KEYHIT
SELECT CASE k
CASE < 0 ‘keyup event
CASE < 27 ‘CTRL-CHARACTER event... also tab, backspace, enter, a few others fall into this range.
CASE > 900000 ‘Extended, non-keyhit codes for buttons QB64 doesn’t usually detect.
CASE ELSE ‘The rest of the stand QB64 KEYHIT codes
END SELECT
The advantage to a completely customizable keyboard routine like this, is like TempodiBasic illustrated: Remapping of keycodes to support international keyboards.
AltGr-E in italian produces an accented “e”... _KEYHIT doesn’t support that, but with his language modification, KEYHIT (the library sub of very similar name)
does.
Remap_KeyCode 191, 151, 0, 21, 0, 0, 0.2: '£
Remap_KeyCode 222, 133, 0, 248, 0, 35, 0.2: '… ø#
Remap_KeyCode 192, 149, 0, 128, 0, 64, 0.2: '• € @
Remap_KeyCode 186, 138, 0, 130, 0, 91, 0.2 'Š ‚ [
(The above is an excerpt from Tempodi’s remapping to allow non-US, and non-QB64 supported, characters to be read and displayed properly with his Italian keyboard.)
Customizable keycodes...
Set them to whatever you need to support your program, language, and keyboard. ;D