Strange. as I’m getting the opposite (as I would have expected). On my side, the tab key respond to key code 48.
Where are you trying your code? Which OS?
Don’t confuse the Tab character and the Tab key. The tab character (the character produced by the Tab key) is ascii 9. The tab key (physically on the keyboard) is the key 48.
Each physical key on the keyboard reports a value to the OS (e.g. 48 for tab, 1 for “s”) and the OS then maps this key to a character, given the user’s chosen layout (9 for tab, 115 for s, etc.). That’s how a specific key can produce e.g. “a” on most keyboard layouts but “q” on the french layout.
Keyboard.AsyncKeyDown checks for the physical value (for tab, 48).
Again: where does this form work for you? It’s illogical, unexpected and doesn’t behave that way on my side.
Was working in Mac.
I had one subroutine out of several keydown areas that was set correctly in Mac. Ignoring that subroutine, I added a the Hex(09) test and ran the software.
It worked but it was reading the Hex(30) routine not the Hex(09) so I incorrectly assumed the Hex(09) fixed it. My other entries all had Hex(33) which of course were incorrect.
It’s all working as expected now. Sorry for the confusion.
Keep in mind that different keyboards can return different key codes. Key codes correspond to the physical keys, not the ascii code that would be used to print the character. That’s why there are key codes for things like the function keys, Home, Del, Arrows and Page Up/Down.
Thanks Emile. I believe you are correct. An old dog like me thinks in terms of ascii codes and hex codes, hence the terms. I’ll need to study up more on the names XOJO uses for the scancodes / rom codes / page codes etc. That would probably have cleared it up for me and could have avoided the post.
At some point in time I believe I had tried
(In the keydown event) MessageBox(key) returned a blank message for non-printable keys but would return the actual key for printable characters. For whatever reason, I would have expected a string or character sequence being returned. I quickly dismissed it and went looking for something else.
At that time, I had switched to the AsyncKeyDown and never looked back.
But yes after looking again, this indeed this also would work.
MessageBox(key.Asc)
MessageBox(key.Asc.ToHex)
I appreciate the feedback