I noticed a difference between the keycodes that vkCode in C++ gives and the ones that Java's KeyEvent gives us. (Ofcourse the normal characters have the same code (0 => 48 just like the ASCII) but they differ in the other keys). Is there a way to 'translate' them from one to the other (What's the logic behind each one?) or am I supposed to use loads of switches and IFs for that. If it helps, my app is half in C++ and half in JAVA because of the Native Hooks that c++ gives us and it gets the keycodes of the keys that the user presses and then the java is going to use them.
Thanks in advance.
or am I supposed to use loads of switches and IFs
You can probably just put them in a lookup table, that is, put the Java KeyCodes in a large array, so you just need to do javaKeyCode = keyLut[cppScanCode].
One list of scan codes can be found here, and the VK_KEYCODES can of course be found in the API docs for KeyEvent.
Java is designed to be platform independent, so pressing the left-key for instance, will always yield a VK_LEFT, no matter scan code. I'm not entirely sure, but I suppose the C++-scancode is hardware dependent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With