It seems that when I press either the ENTER (or RETURN) key on the main keyboard, or the one on the numeric keypad, both Keyboard.AsyncKeyDown(&H24) and Keyboard.AsyncKeyDown(&H4C) return TRUE. (Tested on Windows)
The docs say that &H24 is the RETURN key while &H4C is the NUMERIC ENTER key.
How can I correctly tell which key is actually being pressed?
True, on a Mac these keys are different. The on on the numeric keypad is Enter (which is some kind of Accept), and the other one is Return (Which adds a New Line). On Windows this distinction does not exist.
On Windows to tell which is which, you would need to get the Key Code for the key that was pressed.
Thanks @Emile_Schwarz, the problem I’m having is that on Windows, the keycode for Return and Enter are both returning true when either one is depressed if I poll either of them using Keyboard.AsyncKeyDown and I need to know which one is actually being pressed.
I’m unsure of how to poll key state by ascii code.
Since polling the state finds both keys to be true, I wouldn’t trust a polling method to return an accurate key.
You’ll have to narrow down where you actually need to know this information and use a KeyDown event handler to capture the keycode actually being pressed.
Because I like to spend my time on things besides what I’m supposed to be doing, I have just tested and confirmed that in KeyDown you get different key codes on Windows.
Thanks for the reply. The application I’m writing allows users to select their own system-wide shortcut keys to perform certain actions while they’re in a full-screen game.
Is there any way to capture these keystrokes with KeyDown while the Xojo app doesn’t have focus?
I ended up writing my own Declares using the win32 api. GetAsyncKeyState has the same issue as Xojo and I suspect it’s what they’re using under the hood. Sadly the Windows API is just as broken in terms of telling these two keys apart, and apparently has been so for decades.
Yet there are undoubtedly approaches that are able to tell the difference, I just can’t figure out how.