In my game I use the numpad for moving. Because I also allow players to chat, I don’t want to capture regular keys there like numbers or arrow keys, therefore I would like to require the numlock key to be down. However I can already foresee players contacting that “movement does not work” and I have to tell them to hit the numlock key.
Is there a way to set the numlock state from UE?
Thanks
Are you using C++ or Blueprints and what do you currently have about this key movement?
Any one to answer your question will need to know what is going on.
I’m using C++ and Blueprints. As for your other question, I dont understand. What do you mean with “what I have about this key movement”?
I’m using the keys just like in the the sample project, I set them as axis input values in the project settings, I just used “Num7” and so on instead of arrow keys.
No, none of them has anything to do with my problem, still thanks for trying
I found a solution. This works only on Windows, but then, I don’t know if other OS even have numlock keys, so if you target for other plattforms, you may have to #ifdef this code.
if( 0 == (GetKeyState(VK_NUMLOCK) & 1) )
{
INPUT input[2];
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_KEYBOARD;
input[0].ki.wVk = input[1].ki.wVk = VK_NUMLOCK;
input[1].ki.dwFlags = KEYEVENTF_KEYUP; // THIS IS IMPORTANT
::SendInput(2, input, sizeof(INPUT));
}